ZQuest Classic Coverage Report


Directory: src/
File: src/base/qst.cpp
Date: 2025-05-29 05:18:59
Exec Total Coverage
Lines: 9248 12793 72.3%
Functions: 110 141 78.0%
Branches: 6933 11847 58.5%

Line Branch Exec Source
1 #include "allegro/file.h"
2 #include "base/flags.h"
3 #include "base/general.h"
4 #include "base/util.h"
5 #include "base/version.h"
6 #include "base/zapp.h"
7 #include "base/qrs.h"
8 #include "base/cpool.h"
9 #include "base/autocombo.h"
10 #include "base/packfile.h"
11 #include "base/dmap.h"
12 #include "base/combo.h"
13 #include "base/msgstr.h"
14 #include "base/flags.h"
15 #include <bit>
16 #include <filesystem>
17 #include <memory>
18 #include <optional>
19 #include <stdio.h>
20 #include <cstring>
21 #include <string>
22 #include <map>
23 #include <vector>
24 #include <assert.h>
25 #include <fmt/format.h>
26
27
28 #include "fmt/core.h"
29 #include "base/zc_alleg.h"
30 #include "base/zdefs.h"
31 #include "base/colors.h"
32 #include "tiles.h"
33 #include "base/zsys.h"
34 #include "base/qst.h"
35 #include "defdata.h"
36 #include "subscr.h"
37 #include "sfx.h"
38 #include "base/md5.h"
39 #include "zc/replay.h"
40 #include "zc/zelda.h"
41 #include "zinfo.h"
42 #include "zc/ffscript.h"
43 #include "particles.h"
44 #include "dialog/alert.h"
45 #include "base/misctypes.h"
46 #include "base/initdata.h"
47
48 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
49 extern void setZScriptVersion(int32_t s_version);
50
51 static bool read_ext_zinfo = false, read_zinfo = false;
52 static bool loadquest_report = false;
53 static char const* loading_qst_name = NULL;
54 static std::string last_loaded_qstpath;
55 static byte loading_qst_num = 0;
56 static byte subscr_mode = ssdtMAX;
57 // Very old quests only used a byte for combos, and each screen had a "combo page" to vary
58 // what combos were used. This vector just lets us convert those old quests on load.
59 static std::vector<byte> old_combo_pages;
60
61 dword loading_tileset_flags = 0;
62
63 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0},combo_auto_listpos[MAX_COMBO_COLS]={0};
64 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
65
66 #ifdef _MSC_VER
67 #define strncasecmp _strnicmp
68 #endif
69
70 #ifndef _AL_MALLOC
71 #define _AL_MALLOC(a) _al_malloc(a)
72 #define _AL_FREE(a) _al_free(a)
73 #endif
74
75 using std::string;
76 using std::pair;
77
78 extern int32_t hero_animation_speed; //lower is faster animation
79 extern byte *colordata;
80 extern tiledata *newtilebuf;
81 extern byte *trashbuf;
82 extern itemdata *itemsbuf;
83 extern wpndata *wpnsbuf;
84 extern comboclass *combo_class_buf;
85 extern guydata *guysbuf;
86 extern ZCHEATS zcheats;
87 extern char palnames[MAXLEVELS][17];
88 extern char *byte_conversion(int32_t number, int32_t format);
89 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
90 string zScript;
91 413 std::map<int32_t, script_slot_data > ffcmap;
92 413 std::map<int32_t, script_slot_data > globalmap;
93 413 std::map<int32_t, script_slot_data > genericmap;
94 413 std::map<int32_t, script_slot_data > itemmap;
95 413 std::map<int32_t, script_slot_data > npcmap;
96 413 std::map<int32_t, script_slot_data > ewpnmap;
97 413 std::map<int32_t, script_slot_data > lwpnmap;
98 413 std::map<int32_t, script_slot_data > playermap;
99 413 std::map<int32_t, script_slot_data > dmapmap;
100 413 std::map<int32_t, script_slot_data > screenmap;
101 413 std::map<int32_t, script_slot_data > itemspritemap;
102 413 std::map<int32_t, script_slot_data > comboscriptmap;
103 413 std::map<int32_t, script_slot_data > subscreenmap;
104 void free_newtilebuf();
105 bool combosread=false;
106 bool mapsread=false;
107 bool fixffcs=false;
108 bool fixpolsvoice=false;
109
110 // Each section had a separate, secondary versioning number, but it was never really utilized for
111 // its intended purpose so it's been removed. But we still write something in this field.
112 232 bool write_deprecated_section_cversion(word section_version, PACKFILE* f)
113 {
114 232 return p_iputw(section_version, f);
115 }
116
117 14136 bool read_deprecated_section_cversion(PACKFILE* f)
118 {
119 word unused;
120 14136 return p_igetw(&unused, f);
121 }
122
123 21982 void script_slot_data::update()
124 {
125
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 21976 times.
21982 switch (format)
126 {
127 case SCRIPT_FORMAT_INVALID:
128 6 output = fmt::format("{} --{}", slotname, scriptname);
129 6 break;
130 21976 case SCRIPT_FORMAT_DEFAULT:
131 default:
132 21976 output = fmt::format("{} {}", slotname, scriptname);
133 21976 }
134 21982 }
135
136 char qstdat_string[2048] = { 0 };
137
138 static zinfo* load_tmp_zi = NULL;
139
140 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
141 const byte clavio[9]={97,109,111,110,103,117,115,0};
142
143 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
144 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
145
146 const char *qst_error[] =
147 {
148 "OK","File not found","Invalid quest file",
149 "Version not supported","Obsolete version",
150 "Missing new data" , /* but let it pass in ZQuest */
151 "Internal error occurred", "Invalid password",
152 "Quest title doesn't match saved game", "Save file is for older version of quest; please start new save",
153 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
154 };
155
156 //for legacy quests -DD
157 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
158 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
159 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
160 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
161 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
162 };
163
164 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
165
166
167 char *byte_conversion(int32_t number, int32_t format)
168 {
169 static char num_str[40];
170
171 if(format==-1) //auto
172 {
173 format=1; //bytes
174
175 if(number>1024)
176 {
177 format=2; //kilobytes
178 }
179
180 if(number>1024*1024)
181 {
182 format=3; //megabytes
183 }
184
185 if(number>1024*1024*1024)
186 {
187 format=4; //gigabytes (dude, what are you doing?)
188 }
189 }
190
191 switch(format)
192 {
193 case 1: //bytes
194 sprintf(num_str,"%db",number);
195 break;
196
197 case 2: //kilobytes
198 sprintf(num_str,"%.2fk",float(number)/1024);
199 break;
200
201 case 3: //megabytes
202 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
203 break;
204
205 case 4: //gigabytes
206 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
207 break;
208
209 default:
210 abort();
211 break;
212 }
213
214 return num_str;
215 }
216
217 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
218 {
219 static char num_str1[40];
220 static char num_str2[40];
221 static char num_str[80];
222
223 if(format1==-1) //auto
224 {
225 format1=1; //bytes
226
227 if(number1>1024)
228 {
229 format1=2; //kilobytes
230 }
231
232 if(number1>1024*1024)
233 {
234 format1=3; //megabytes
235 }
236
237 if(number1>1024*1024*1024)
238 {
239 format1=4; //gigabytes (dude, what are you doing?)
240 }
241 }
242
243 if(format2==-1) //auto
244 {
245 format2=1; //bytes
246
247 if(number2>1024)
248 {
249 format2=2; //kilobytes
250 }
251
252 if(number2>1024*1024)
253 {
254 format2=3; //megabytes
255 }
256
257 if(number2>1024*1024*1024)
258 {
259 format2=4; //gigabytes (dude, what are you doing?)
260 }
261 }
262
263 switch(format1)
264 {
265 case 1: //bytes
266 sprintf(num_str1,"%db",number1);
267 break;
268
269 case 2: //kilobytes
270 sprintf(num_str1,"%.2fk",float(number1)/1024);
271 break;
272
273 case 3: //megabytes
274 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
275 break;
276
277 case 4: //gigabytes
278 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
279 break;
280
281 default:
282 abort();
283 break;
284 }
285
286 switch(format2)
287 {
288 case 1: //bytes
289 sprintf(num_str2,"%db",number2);
290 break;
291
292 case 2: //kilobytes
293 sprintf(num_str2,"%.2fk",float(number2)/1024);
294 break;
295
296 case 3: //megabytes
297 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
298 break;
299
300 case 4: //gigabytes
301 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
302 break;
303
304 default:
305 abort();
306 break;
307 }
308
309 sprintf(num_str, "%s/%s", num_str1, num_str2);
310 return num_str;
311 }
312
313 char *ordinal(int32_t num)
314 {
315 static const char *ending[4] = {"st","nd","rd","th"};
316 static char ord_str[8];
317
318 char *end;
319 int32_t t=(num%100)/10;
320 int32_t n=num%10;
321
322 if(n>=1 && n<4 && t!=1)
323 end = (char *)ending[n-1];
324 else
325 end = (char *)ending[3];
326
327 sprintf(ord_str,"%d%s",num%10000,end);
328 return ord_str;
329 }
330
331 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
332 {
333 int32_t ret;
334 *version=0;
335 *build=0;
336 byte temp_map_count=map_count;
337 byte temp_midi_flags[MIDIFLAGS_SIZE];
338 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
339
340 zquestheader tempheader{};
341
342 if(!f)
343 {
344 return qe_invalid;
345 }
346
347 ret=readheader(f, &tempheader);
348
349 if(ret)
350 {
351 return ret;
352 }
353
354 map_count=temp_map_count;
355 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
356 *version=tempheader.zelda_version;
357 *build=tempheader.build;
358 return 0;
359 }
360
361
362 bool find_section(PACKFILE *f, int32_t section_id_requested)
363 {
364
365 if(!f)
366 {
367 return false;
368 }
369
370 int32_t section_id_read;
371 bool catchup=false;
372 word dummy;
373 byte tempbyte;
374 char tempbuf[65536];
375
376
377 switch(section_id_requested)
378 {
379 case ID_RULES:
380 case ID_STRINGS:
381 case ID_MISC:
382 case ID_TILES:
383 case ID_COMBOS:
384 case ID_CSETS:
385 case ID_MAPS:
386 case ID_DMAPS:
387 case ID_DOORS:
388 case ID_ITEMS:
389 case ID_WEAPONS:
390 case ID_COLORS:
391 case ID_ICONS:
392 case ID_INITDATA:
393 case ID_GUYS:
394 case ID_MIDIS:
395 case ID_CHEATS:
396 break;
397
398 default:
399 al_trace("Bad section requested!\n");
400 return false;
401 break;
402 }
403
404 dword section_size;
405
406 //section id
407 if(!p_mgetl(&section_id_read,f))
408 {
409 return false;
410 }
411
412 while(!pack_feof(f))
413 {
414 switch(section_id_read)
415 {
416 case ID_RULES:
417 case ID_STRINGS:
418 case ID_MISC:
419 case ID_TILES:
420 case ID_COMBOS:
421 case ID_CSETS:
422 case ID_MAPS:
423 case ID_DMAPS:
424 case ID_DOORS:
425 case ID_ITEMS:
426 case ID_WEAPONS:
427 case ID_COLORS:
428 case ID_ICONS:
429 case ID_INITDATA:
430 case ID_GUYS:
431 case ID_MIDIS:
432 case ID_CHEATS:
433 catchup=false;
434 break;
435
436 default:
437 break;
438 }
439
440
441 while(catchup)
442 {
443 //section id
444 section_id_read=(section_id_read<<8);
445
446 if(!p_getc(&tempbyte,f))
447 {
448 return false;
449 }
450
451 section_id_read+=tempbyte;
452 }
453
454 if(section_id_read==section_id_requested)
455 {
456 return true;
457 }
458 else
459 {
460 //section version info
461 if(!p_igetw(&dummy,f))
462 {
463 return false;
464 }
465
466 if(!p_igetw(&dummy,f))
467 {
468 return false;
469 }
470
471 //section size
472 if(!p_igetl(&section_size,f))
473 {
474 return false;
475 }
476
477 //pack_fseek(f, section_size);
478 while(section_size>65535)
479 {
480 pfread(tempbuf,65535,f);
481 tempbuf[65535]=0;
482 section_size-=65535;
483 }
484
485 if(section_size>0)
486 {
487 pfread(tempbuf,section_size,f);
488 tempbuf[section_size]=0;
489 }
490 }
491
492 //section id
493 if(!p_mgetl(&section_id_read,f))
494 {
495 return false;
496 }
497 }
498
499 return false;
500 }
501
502
503
504
505
506 bool valid_zqt(PACKFILE *f)
507 {
508
509 //word tiles_used;
510 //word combos_used;
511 //open the file
512 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
513 if(!f)
514 return false;
515
516 //for now, everything else is valid
517 return true;
518
519 /*int16_t version;
520 byte build;
521
522 //read the version and make sure it worked
523 if(!p_igetw(&version,f))
524 {
525 goto error;
526 }
527
528 //read the build and make sure it worked
529 if(!p_getc(&build,f))
530 goto error;
531
532 //read the tile info and make sure it worked
533 if(!p_igetw(&tiles_used,f))
534 {
535 goto error;
536 }
537
538 for (int32_t i=0; i<tiles_used; i++)
539 {
540 if(!pfread(trashbuf,tilesize(tf4Bit),f))
541 {
542 goto error;
543 }
544 }
545
546 //read the combo info and make sure it worked
547 if(!p_igetw(&combos_used,f))
548 {
549 goto error;
550 }
551 for (int32_t i=0; i<combos_used; i++)
552 {
553 if(!pfread(trashbuf,sizeof(newcombo),f))
554 {
555 goto error;
556 }
557 }
558
559 //read the palette info and make sure it worked
560 for (int32_t i=0; i<48; i++)
561 {
562 if(!pfread(trashbuf,newpdTOTAL,f))
563 {
564 goto error;
565 }
566 }
567 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
568 {
569 goto error;
570 }
571 for (int32_t i=0; i<MAXLEVELS; i++)
572 {
573 if(!pfread(trashbuf,PALNAMESIZE,f))
574 {
575 goto error;
576 }
577 }
578
579 //read the sprite info and make sure it worked
580 for (int32_t i=0; i<MAXITEMS; i++)
581 {
582 if(!pfread(trashbuf,sizeof(itemdata),f))
583 {
584 goto error;
585 }
586 }
587
588 for (int32_t i=0; i<MAXWPNS; i++)
589 {
590 if(!pfread(trashbuf,sizeof(wpndata),f))
591 {
592 goto error;
593 }
594 }
595
596 //read the triforce pieces info and make sure it worked
597 for (int32_t i=0; i<8; ++i)
598 {
599 if(!p_getc(&trashbuf,f))
600 {
601 goto error;
602 }
603 }
604
605
606
607 //read the game icons info and make sure it worked
608 for (int32_t i=0; i<4; ++i)
609 {
610 if(!p_igetw(&trashbuf,f))
611 {
612 goto error;
613 }
614 }
615
616 //read the misc colors info and map styles info and make sure it worked
617 if(!pfread(trashbuf,sizeof(zcolors),f))
618 {
619 goto error;
620 }
621
622 //read the template screens and make sure it worked
623 byte num_maps;
624 if(!p_getc(&num_maps,f))
625 {
626 goto error;
627 }
628 for (int32_t i=0; i<TEMPLATES; i++)
629 {
630 if(!pfread(trashbuf,sizeof(mapscr),f))
631 {
632 goto error;
633 }
634 }
635 if (num_maps>1) //dungeon templates
636 {
637 for (int32_t i=0; i<TEMPLATES; i++)
638 {
639 if(!pfread(trashbuf,sizeof(mapscr),f))
640 {
641 goto error;
642 }
643 }
644 }
645
646 //yay! it worked! close the file and say everything was ok.
647 pack_fclose(f);
648 return true;
649
650 error:
651 pack_fclose(f);
652 return false;*/
653 }
654
655 bool valid_zqt(const char *filename)
656 {
657 PACKFILE *f=NULL;
658 bool isvalid;
659 int32_t error;
660 f=open_quest_file(&error, filename, false);
661
662 if(!f)
663 {
664 // setPackfilePassword(NULL);
665 return false;
666 }
667
668 isvalid=valid_zqt(f);
669
670 clear_quest_tmpfile();
671 pack_fclose(f);
672
673 // setPackfilePassword(NULL);
674 return isvalid;
675 }
676
677 /*
678 .qst file history
679
680 .qst files have always been compressed using allegro's packfiles.
681
682 At some point, an encoding layer was added. The two layers look like this:
683
684 1) The top layer is from us. See decode_file_007.
685 [0-24] Preamble "Zelda Classic Quest File"
686 [25-28] Initial decoding seed value.
687 [29-X] Allegro-compressed payload (AKA "packed" file), but XOR'd based on seed value
688 [last 4] Checksum
689
690 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
691 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
692 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
693 The oldest quests skip the password part.
694
695 Simply, the job of this function is to peel away the top layer.
696
697 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
698 in opening and saving files. There is no version field, so they decryption key is
699 found via trial-by-error (very slow!)
700
701 There are other file types of interest:
702 - .zqt: quest template files, skips top-layer encryption pass
703 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
704 - .qu?: same as above. automated backup files
705 - .qb?: same as above. automated backup files
706 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
707
708 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
709 files are now "slh!.AG ZC Enhanced Quest File".
710 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
711 */
712 781 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
713 {
714
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 if (show_progress)
715 {
716 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
717 }
718
719 781 auto unencrypted_result = try_open_maybe_legacy_encoded_file(filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
720
2/2
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 479 times.
781 if (unencrypted_result.decoded_pf)
721 302 return unencrypted_result.decoded_pf;
722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 479 times.
479 if (unencrypted_result.not_found)
723 {
724 *open_error = qe_notfound;
725 return nullptr;
726 }
727
728 // Everything below here is legacy code - recently saved quest files will have
729 // returned by now.
730 // The only replay qst file that is still using this legacy encoding is `link_to_the_zelda.qst`.
731
732 // Note: although this is primarily for loading .qst files, it can also handle all of the
733 // file types mentioned in the comment above. No need to be told if the file being loaded
734 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
735 479 bool top_layer_compressed = unencrypted_result.top_layer_compressed;
736 479 bool compressed = unencrypted_result.compressed;
737 479 bool encrypted = unencrypted_result.encrypted;
738
739 char tmpfilename[L_tmpnam];
740 479 temp_name(tmpfilename);
741 char percent_done[30];
742 479 int32_t current_method=0;
743
744 PACKFILE *f;
745 479 const char *passwd= encrypted ? datapwd : "";
746
747 // oldquest flag is set when an unencrypted qst file is suspected.
748 479 bool oldquest = false;
749 int32_t ret;
750
751
1/2
✓ Branch 0 taken 479 times.
✗ Branch 1 not taken.
479 if(strcmp(filename, "default.qst")!=0)
752 {
753 479 box_out(filename);
754 479 }
755 else
756 {
757 box_out("new quest"); // Or whatever
758 }
759 479 box_out("...");
760 479 box_eol();
761 479 box_eol();
762
763
1/2
✓ Branch 0 taken 479 times.
✗ Branch 1 not taken.
479 if(encrypted)
764 {
765 479 box_out("Decrypting...");
766 479 box_save_x();
767 479 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
768
769
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 63 times.
479 if(ret)
770 {
771
1/3
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
63 switch(ret)
772 {
773 case 1:
774 box_out("error.");
775 box_eol();
776 box_end(true);
777 *open_error=qe_notfound;
778 return NULL;
779
780 case 2:
781 box_out("error.");
782 box_eol();
783 box_end(true);
784 *open_error=qe_internal;
785 return NULL;
786 // be sure not to delete tmpfilename now...
787 }
788
789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
790 {
791 63 current_method++;
792 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
793 63 box_out(percent_done);
794 63 box_load_x();
795 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
796 63 }
797
798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
799 {
800 63 current_method++;
801 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
802 63 box_out(percent_done);
803 63 box_load_x();
804 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
805 63 }
806
807
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 18 times.
63 if(ret==5) //old encryption?
808 {
809 18 current_method++;
810 18 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
811 18 box_out(percent_done);
812 18 box_load_x();
813 18 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
814 18 }
815
816
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 12 times.
63 if(ret==5) //old encryption?
817 {
818 12 current_method++;
819 12 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
820 12 box_out(percent_done);
821 12 box_load_x();
822 12 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
823 12 }
824
825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret)
826 {
827 oldquest = true;
828 passwd="";
829 }
830 63 }
831
832 479 box_out("okay.");
833 479 box_eol();
834 479 }
835 else
836 {
837 oldquest = true;
838 }
839
840 479 box_out("Opening...");
841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 479 times.
479 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
842
1/2
✓ Branch 0 taken 479 times.
✗ Branch 1 not taken.
479 if(!f)
843 {
844 if((compressed==1)&&(errno==EDOM))
845 {
846 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
847 }
848
849 if(!f)
850 {
851 if(!oldquest)
852 {
853 delete_file(tmpfilename);
854 }
855 box_out("error.");
856 box_eol();
857 box_end(true);
858 *open_error=qe_invalid;
859 return NULL;
860 }
861 }
862
863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 479 times.
479 if(!oldquest)
864 {
865 479 delete_file(tmpfilename);
866 479 }
867
868 479 box_out("okay.");
869 479 box_eol();
870
871 479 return f;
872 781 }
873
874 PACKFILE *open_quest_template(zquestheader *Header, const char *filename, bool validate)
875 {
876 PACKFILE *f=NULL;
877 int32_t open_error=0;
878
879 if (Header->templatepath[0] != 0)
880 {
881 // TODO: should be safe to remove this, no one seems to use custom quest templates.
882 filename=Header->templatepath;
883 }
884
885 f=open_quest_file(&open_error, filename, false);
886
887 if(!f)
888 {
889 return NULL;
890 }
891
892 if(validate)
893 {
894 if(!valid_zqt(f))
895 {
896 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
897 pack_fclose(f);
898 clear_quest_tmpfile();
899 return NULL;
900 }
901 }
902
903 return f;
904 }
905
906 static bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate, const char* filename)
907 {
908 // The only time the player uses this is to init tiles for some quests 1.90 or older. See readtiles.
909 if (get_app_id() == App::zelda)
910 assert(section_id == ID_TILES);
911
912 combosread=false;
913 mapsread=false;
914 fixffcs=false;
915
916 switch(section_id)
917 {
918 case ID_RULES:
919 case ID_STRINGS:
920 case ID_MISC:
921 case ID_TILES:
922 case ID_COMBOS:
923 case ID_CSETS:
924 case ID_MAPS:
925 case ID_DMAPS:
926 case ID_DOORS:
927 case ID_ITEMS:
928 case ID_WEAPONS:
929 case ID_COLORS:
930 case ID_ICONS:
931 case ID_INITDATA:
932 case ID_GUYS:
933 case ID_MIDIS:
934 case ID_CHEATS:
935 case ID_ITEMDROPSETS:
936 case ID_FAVORITES:
937 break;
938
939 default:
940 return false;
941 break;
942 }
943
944 int32_t ret;
945 word version, build;
946 PACKFILE *f=NULL;
947
948 //why is this here?
949 /*
950 if(colordata==NULL)
951 return false;
952 */
953
954 //setPackfilePassword(datapwd);
955 f=open_quest_template(Header, filename, validate);
956
957 if(!f) //no file, nothing to delete
958 {
959 // setPackfilePassword(NULL);
960 return false;
961 }
962
963 ret=get_version_and_build(f, &version, &build);
964
965 if(ret||(version==0))
966 {
967 pack_fclose(f);
968 clear_quest_tmpfile();
969
970 // setPackfilePassword(NULL);
971 return false;
972 }
973
974 if(!find_section(f, section_id))
975 {
976 al_trace("Can't find section!\n");
977 pack_fclose(f);
978 clear_quest_tmpfile();
979
980 //setPackfilePassword(NULL);
981 return false;
982 }
983
984 switch(section_id)
985 {
986 case ID_RULES:
987 //rules
988 ret=readrules(f, Header);
989 break;
990
991 case ID_STRINGS:
992 //strings
993 ret=readstrings(f, Header);
994 break;
995
996 case ID_MISC:
997 //misc data
998 ret=readmisc(f, Header, Misc);
999 break;
1000
1001 case ID_TILES:
1002 //tiles
1003 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1004 break;
1005
1006 case ID_COMBOS:
1007 //combos
1008 clear_combos();
1009 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1010 combosread=true;
1011 break;
1012
1013 case ID_COMBOALIASES:
1014 //combos
1015 ret=readcomboaliases(f, Header, version, build);
1016 break;
1017
1018 case ID_CSETS:
1019 //color data
1020 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1021 break;
1022
1023 case ID_MAPS:
1024 //maps
1025 ret=readmaps(f, Header);
1026 mapsread=true;
1027 break;
1028
1029 case ID_DMAPS:
1030 //dmaps
1031 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1032 break;
1033
1034 case ID_DOORS:
1035 //door combo sets
1036 ret=readdoorcombosets(f, Header);
1037 break;
1038
1039 case ID_ITEMS:
1040 //items
1041 ret=readitems(f, version, build);
1042 break;
1043
1044 case ID_WEAPONS:
1045 //weapons
1046 ret=readweapons(f, Header);
1047 break;
1048
1049 case ID_COLORS:
1050 //misc. colors
1051 ret=readmisccolors(f, Header, Misc);
1052 break;
1053
1054 case ID_ICONS:
1055 //game icons
1056 ret=readgameicons(f, Header, Misc);
1057 break;
1058
1059 case ID_INITDATA:
1060 //initialization data
1061 ret=readinitdata(f, Header);
1062 break;
1063
1064 case ID_GUYS:
1065 //guys
1066 ret=readguys(f, Header);
1067 break;
1068
1069 case ID_MIDIS:
1070 //midis
1071 ret=readtunes(f, Header, tunes);
1072 break;
1073
1074 case ID_CHEATS:
1075 //cheat codes
1076 ret=readcheatcodes(f, Header);
1077 break;
1078
1079 case ID_ITEMDROPSETS:
1080 //item drop sets
1081 // Why is this one commented out?
1082 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1083 break;
1084
1085 case ID_FAVORITES:
1086 // favorite combos and aliases
1087 ret=readfavorites(f, version);
1088 break;
1089
1090 default:
1091 ret=-1;
1092 break;
1093 }
1094
1095 pack_fclose(f);
1096 clear_quest_tmpfile();
1097
1098 //setPackfilePassword(NULL);
1099 if(!ret)
1100 {
1101 return true;
1102 }
1103
1104 return false;
1105 }
1106
1107 bool init_tiles_for_190(bool validate, zquestheader *Header)
1108 {
1109 return init_section(Header, ID_TILES, NULL, NULL, validate, "assets/190_tiles.qst");
1110 }
1111
1112 bool init_tiles(bool validate, zquestheader *Header)
1113 {
1114 return init_section(Header, ID_TILES, NULL, NULL, validate, "modules/classic/default.qst");
1115 }
1116
1117 bool init_combos(bool validate, zquestheader *Header)
1118 {
1119 return init_section(Header, ID_COMBOS, NULL, NULL, validate, "modules/classic/default.qst");
1120 }
1121
1122 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1123 {
1124 return init_section(Header, ID_CSETS, Misc, NULL, validate, "modules/classic/default.qst");
1125 }
1126
1127 781 void init_spritelists()
1128 {
1129
2/2
✓ Branch 0 taken 602 times.
✓ Branch 1 taken 179 times.
781 if(FFCore.quest_format[vZelda] < 0x255)
1130 {
1131 602 guys.setMax(255);
1132 602 items.setMax(255);
1133 602 Ewpns.setMax(255);
1134 602 Lwpns.setMax(255);
1135 602 chainlinks.setMax(255);
1136 602 decorations.setMax(255);
1137 602 particles.setMax(255);
1138 602 }
1139 else
1140 {
1141 179 guys.setMax(255);
1142 179 items.setMax(255);
1143 179 Ewpns.setMax(255);
1144 179 Lwpns.setMax(255);
1145 179 chainlinks.setMax(255);
1146 179 decorations.setMax(255);
1147 179 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1148 }
1149 781 }
1150
1151 306 bool reset_items(bool validate, zquestheader *Header)
1152 {
1153 306 bool ret = true;
1154
1/2
✓ Branch 0 taken 306 times.
✗ Branch 1 not taken.
306 if (get_app_id() == App::zquest)
1155 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate, "modules/classic/default.qst");
1156
1157
2/2
✓ Branch 0 taken 306 times.
✓ Branch 1 taken 78336 times.
78642 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1158
1159 306 return ret;
1160 }
1161
1162 bool reset_guys()
1163 {
1164 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1165 init_guys(V_GUYS);
1166 return true;
1167 }
1168
1169 bool reset_wpns(bool validate, zquestheader *Header)
1170 {
1171 bool ret = true;
1172 if (get_app_id() == App::zquest)
1173 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate, "modules/classic/default.qst");
1174
1175 for(int32_t i=0; i<MAXWPNS; i++)
1176 reset_weaponname(i);
1177
1178 return ret;
1179 }
1180
1181 bool reset_mapstyles(bool validate, miscQdata *Misc)
1182 {
1183 Misc->colors.blueframe_tile = 20044;
1184 Misc->colors.blueframe_cset = 0;
1185 Misc->colors.triforce_tile = 23461;
1186 Misc->colors.triforce_cset = 1;
1187 Misc->colors.triframe_tile = 18752;
1188 Misc->colors.triframe_cset = 1;
1189 Misc->colors.overworld_map_tile = 16990;
1190 Misc->colors.overworld_map_cset = 2;
1191 Misc->colors.HCpieces_tile = 21160;
1192 Misc->colors.HCpieces_cset = 8;
1193 Misc->colors.dungeon_map_tile = 19651;
1194 Misc->colors.dungeon_map_cset = 8;
1195 return true;
1196 }
1197
1198 362 int32_t get_qst_buffers()
1199 {
1200 362 TheMaps.resize(MAPSCRS);
1201 362 old_combo_pages.resize(MAPSCRS);
1202 362 map_autolayers.resize(6);
1203
1204 362 Z_message("OK\n");
1205
1206 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1207 // (Shoelace's "Hero of Dreams" uses 1415.)
1208 // So let's be a bit generous and allow 4096 initially.
1209 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1210 // I tested it and it worked without flaw on 6/6/11. - L.
1211 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1212 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1213 // See https://discord.com/channels/876899628556091432/992984989073416242
1214 362 msg_strings_size = 8192;
1215
1216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 362 times.
362 MsgStrings = new MsgStr[msg_strings_size];
1217
1218 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1219
2/2
✓ Branch 0 taken 2965504 times.
✓ Branch 1 taken 362 times.
2965866 for(auto q = 0; q < msg_strings_size; ++q)
1220 {
1221 2965504 MsgStrings[q].clear();
1222 2965504 }
1223
1224
1/2
✓ Branch 0 taken 362 times.
✗ Branch 1 not taken.
362 if((DMaps=new dmap[MAXDMAPS])==NULL)
1225 return 0;
1226
1227
1228
1229 362 combobuf.clear();
1230 362 combobuf.resize(MAXCOMBOS);
1231
1232
1233
1/2
✓ Branch 0 taken 362 times.
✗ Branch 1 not taken.
362 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1234 return 0;
1235
1236 362 free_newtilebuf();
1237
1/2
✓ Branch 0 taken 362 times.
✗ Branch 1 not taken.
362 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1238 return 0;
1239
1240 362 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1241 //Z_message("Performed memset on tiles\n");
1242 362 clear_tiles(newtilebuf);
1243 //Z_message("Performed clear_tiles()\n");
1244
1245
2/2
✓ Branch 0 taken 349 times.
✓ Branch 1 taken 13 times.
362 if (get_app_id() == App::zquest)
1246 {
1247
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1248 return 0;
1249
1250 13 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1251 13 clear_tiles(grabtilebuf);
1252 13 }
1253
1254
1/2
✓ Branch 0 taken 362 times.
✗ Branch 1 not taken.
362 if((trashbuf=(byte*)malloc(100000))==NULL)
1255 return 0;
1256
1257 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1258 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1259 // fixed by ensuring there's actually itemdata there.
1260 // If you change this, be sure to update del_qst_buffers, too.
1261
1262
1/2
✓ Branch 0 taken 362 times.
✗ Branch 1 not taken.
362 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1263 return 0;
1264
1265 362 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1266 362 itemsbuf++;
1267
1268
1/2
✓ Branch 0 taken 362 times.
✗ Branch 1 not taken.
362 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1269 return 0;
1270
1271 362 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1272
1273
1/2
✓ Branch 0 taken 362 times.
✗ Branch 1 not taken.
362 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1274 return 0;
1275
1276 362 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1277
1278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 362 times.
362 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1279 return 0;
1280
1281 362 return 1;
1282 362 }
1283
1284
1285 679 void free_newtilebuf()
1286 {
1287
2/2
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 361 times.
679 if(newtilebuf)
1288 {
1289
2/2
✓ Branch 0 taken 68211000 times.
✓ Branch 1 taken 318 times.
68211318 for(int32_t i=0; i<NEWMAXTILES; i++)
1290
2/2
✓ Branch 0 taken 214500 times.
✓ Branch 1 taken 67996500 times.
136207500 if(newtilebuf[i].data)
1291 67996500 free(newtilebuf[i].data);
1292
1293 318 free(newtilebuf);
1294 318 newtilebuf = 0;
1295 318 }
1296 679 }
1297
1298 317 void free_grabtilebuf()
1299 {
1300
2/2
✓ Branch 0 taken 306 times.
✓ Branch 1 taken 11 times.
317 if (get_app_id() == App::zquest)
1301 {
1302
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(grabtilebuf)
1303 {
1304
2/2
✓ Branch 0 taken 2359500 times.
✓ Branch 1 taken 11 times.
2359511 for(int32_t i=0; i<NEWMAXTILES; i++)
1305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2359500 times.
2359500 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1306
1307 11 free(grabtilebuf);
1308 11 grabtilebuf = 0;
1309 11 }
1310 11 }
1311 317 }
1312
1313 317 void del_qst_buffers()
1314 {
1315
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
✓ Branch 2 taken 317 times.
✗ Branch 3 not taken.
317 if(MsgStrings) delete[] MsgStrings;
1316
1317
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
✓ Branch 2 taken 317 times.
✗ Branch 3 not taken.
317 if (DMaps) delete[] DMaps;
1318
1319 317 combobuf.clear();
1320
1321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
317 if(colordata) free(colordata);
1322
1323 317 free_newtilebuf();
1324 317 free_grabtilebuf();
1325
1326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
317 if(trashbuf) free(trashbuf);
1327
1328 // See get_qst_buffers
1329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
317 if(itemsbuf)
1330 {
1331 317 itemsbuf--;
1332 317 free(itemsbuf);
1333 317 }
1334
1335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
317 if(wpnsbuf) free(wpnsbuf);
1336
1337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
317 if(guysbuf) free(guysbuf);
1338
1339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
317 if(combo_class_buf) free(combo_class_buf);
1340 317 }
1341
1342 18 bool init_palnames()
1343 {
1344 // if(palnames==NULL)
1345 // return false;
1346
1347
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 18 times.
9234 for(int32_t x=0; x<MAXLEVELS; x++)
1348 {
1349
4/4
✓ Branch 0 taken 9162 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 18 times.
9216 switch(x)
1350 {
1351 case 0:
1352 18 sprintf(palnames[x],"Overworld");
1353 18 break;
1354
1355 case 10:
1356 18 sprintf(palnames[x],"Caves");
1357 18 break;
1358
1359 case 11:
1360 18 sprintf(palnames[x],"Passageways");
1361 18 break;
1362
1363 default:
1364 9162 sprintf(palnames[x],"%c",0);
1365 9162 break;
1366 }
1367 9216 }
1368
1369 18 return true;
1370 }
1371
1372 100066 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1373 {
1374 void *p;
1375
1376
1/2
✓ Branch 0 taken 100066 times.
✗ Branch 1 not taken.
100066 p = _AL_MALLOC(MAX(size, alloc_size));
1377
1378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100066 times.
100066 if(!p)
1379 {
1380 return NULL;
1381 }
1382
1383
1/2
✓ Branch 0 taken 100066 times.
✗ Branch 1 not taken.
100066 if(!pfread(p,size,f))
1384 {
1385 _AL_FREE(p);
1386 return NULL;
1387 }
1388
1389
1/2
✓ Branch 0 taken 100066 times.
✗ Branch 1 not taken.
100066 if(pack_ferror(f))
1390 {
1391 _AL_FREE(p);
1392 return NULL;
1393 }
1394
1395 100066 return p;
1396 100066 }
1397
1398 // Only use for reading parts of older quests (Header->zelda_version <= 0x192)
1399 static const byte* legacy_skip_flags;
1400
1401 /* read_midi:
1402 * Reads MIDI data from a datafile (this is not the same thing as the
1403 * standard midi file format).
1404 */
1405
1406 10238 static MIDI *read_midi(PACKFILE *f)
1407 {
1408 MIDI *m;
1409 int32_t c;
1410 10238 int16_t divisions=0;
1411 10238 int32_t len=0;
1412
1413 10238 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1414
1415
1/2
✓ Branch 0 taken 10238 times.
✗ Branch 1 not taken.
10238 if(!m)
1416 {
1417 return NULL;
1418 }
1419
1420
2/2
✓ Branch 0 taken 327616 times.
✓ Branch 1 taken 10238 times.
337854 for(c=0; c<MIDI_TRACKS; c++)
1421 {
1422 327616 m->track[c].len = 0;
1423 327616 m->track[c].data = NULL;
1424 327616 }
1425
1426 10238 p_mgetw(&divisions,f);
1427 10238 m->divisions=divisions;
1428
1429
2/2
✓ Branch 0 taken 327616 times.
✓ Branch 1 taken 10238 times.
337854 for(c=0; c<MIDI_TRACKS; c++)
1430 {
1431 327616 p_mgetl(&len,f);
1432 327616 m->track[c].len=len;
1433
1434
2/2
✓ Branch 0 taken 227550 times.
✓ Branch 1 taken 100066 times.
327616 if(m->track[c].len > 0)
1435 {
1436 100066 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1437
1438
1/2
✓ Branch 0 taken 100066 times.
✗ Branch 1 not taken.
100066 if(!m->track[c].data)
1439 {
1440 destroy_midi(m);
1441 return NULL;
1442 }
1443 100066 }
1444 327616 }
1445
1446 LOCK_DATA(m, sizeof(MIDI));
1447
1448
2/2
✓ Branch 0 taken 327616 times.
✓ Branch 1 taken 10238 times.
337854 for(c=0; c<MIDI_TRACKS; c++)
1449 {
1450
2/2
✓ Branch 0 taken 100066 times.
✓ Branch 1 taken 227550 times.
327616 if(m->track[c].data)
1451 {
1452 LOCK_DATA(m->track[c].data, m->track[c].len);
1453 100066 }
1454 327616 }
1455
1456 10238 return m;
1457 10238 }
1458
1459 void clear_combo(int32_t i)
1460 {
1461 combobuf[i].clear();
1462 }
1463
1464 void clear_combos()
1465 {
1466 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1467 clear_combo(tmpcounter);
1468 }
1469
1470 void pack_combos()
1471 {
1472 int32_t di = 0;
1473
1474 for(int32_t si=0; si<1024; si+=2)
1475 combobuf[di++] = combobuf[si];
1476
1477 for(; di<1024; di++)
1478 clear_combo(di);
1479 }
1480
1481 466 void reset_tunes(zctune *tune)
1482 {
1483
2/2
✓ Branch 0 taken 117432 times.
✓ Branch 1 taken 466 times.
117898 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1484 {
1485 117432 tune[i].reset();
1486 117432 }
1487 466 }
1488
1489
1490 /*void reset_midi(zcmidi_ *m)
1491 {
1492 m->title[0]=0;
1493 m->loop=1;
1494 m->volume=144;
1495 m->start=0;
1496 m->loop_start=-1;
1497 m->loop_end=-1;
1498 if(m->midi)
1499 {
1500 destroy_midi(m->midi);
1501 }
1502 m->midi=NULL;
1503 }
1504
1505
1506 void reset_midis(zcmidi_ *m)
1507 {
1508 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1509 {
1510 reset_midi(m+i);
1511 }
1512 }
1513 */
1514
1515 void reset_scr(int32_t scr)
1516 {
1517 /*
1518 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1519 for(unsigned i=0; i<sizeof(mapscr); i++)
1520 *(di++) = 0;
1521 TheMaps[scr].valid=mVERSION;
1522 */
1523
1524 TheMaps[scr].zero_memory();
1525 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1526
1527 for(int32_t i=0; i<6; i++)
1528 {
1529 //these will be uncommented later
1530 //TheMaps[scr].layerxsize[i]=16;
1531 //TheMaps[scr].layerysize[i]=11;
1532 TheMaps[scr].layeropacity[i]=255;
1533 }
1534
1535 TheMaps[scr].valid=mVERSION;
1536
1537 }
1538
1539 int32_t doortranslations_u[9][4]=
1540 {
1541 {37,38,53,54},
1542 {37,38,39,40},
1543 {37,38,55,56},
1544 {37,38,39,40},
1545 {37,38,53,54},
1546 {37,38,53,54},
1547 {37,38,53,54},
1548 {7,8,23,24},
1549 {7,8,41,42}
1550 };
1551
1552 int32_t doortranslations_d[9][4]=
1553 {
1554 {117,118,133,134},
1555 {135,136,133,134},
1556 {119,120,133,134},
1557 {135,136,133,134},
1558 {117,118,133,134},
1559 {117,118,133,134},
1560 {117,118,133,134},
1561 {151,152,167,168},
1562 {137,138,167,168},
1563 };
1564
1565 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1566 int32_t doortranslations_l[9][6]=
1567 {
1568 {66,67,82,83,98,99},
1569 {66,68,82,84,98,100},
1570 {66,69,82,85,98,101},
1571 {66,68,82,84,98,100},
1572 {66,67,82,83,98,99},
1573 {66,67,82,83,98,99},
1574 {66,67,82,83,98,99},
1575 {64,65,80,81,96,97},
1576 {64,65,80,114,96,97},
1577 };
1578
1579 int32_t doortranslations_r[9][6]=
1580 {
1581
1582 {76,77,92,93,108,109},
1583 {75,77,91,93,107,109},
1584 {74,77,90,93,106,109},
1585 {75,77,91,93,107,109},
1586 {76,77,92,93,108,109},
1587 {76,77,92,93,108,109},
1588 {76,77,92,93,108,109},
1589 {78,79,94,95,110,111},
1590 {78,79,125,95,110,111},
1591 };
1592
1593 858450 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1594 {
1595 858450 byte old_cpage = old_combo_pages[map*MAPSCRS+scr];
1596 858450 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF) + (old_cpage<<8);
1597 }
1598
1599 840750 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1600 {
1601 //these are here to bypass compiler warnings about unused arguments
1602 840750 map=map;
1603 840750 scr=scr;
1604 840750 pos=pos;
1605
1606 //what does this function do?
1607 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1608 840750 return 2;
1609 }
1610
1611 22848 int32_t MakeDoors(int32_t map, int32_t scr)
1612 {
1613
2/2
✓ Branch 0 taken 18423 times.
✓ Branch 1 taken 4425 times.
22848 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1614 {
1615 18423 return 0;
1616 }
1617
1618 4425 DoorComboSet tempdcs{};
1619
1620 //up
1621
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1622 {
1623
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1624 {
1625 159300 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1626 159300 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1627 159300 }
1628 39825 }
1629
1630 4425 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1631 4425 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1632 4425 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1633 4425 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1634 4425 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1635 4425 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1636
1637 //down
1638
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1639 {
1640
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1641 {
1642 159300 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1643 159300 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1644 159300 }
1645 39825 }
1646
1647 4425 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1648
1649 4425 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1650 4425 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1651 4425 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1652 4425 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1653 4425 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1654
1655 //left
1656 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1657
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1658 {
1659
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1660 {
1661 238950 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1662 238950 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1663 238950 }
1664 39825 }
1665
1666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1667 {
1668 if((j!=2)&&(j!=3))
1669 {
1670 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1671 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1672 }
1673 }
1674
1675 4425 tempdcs.bombdoorcombo_l[0]=0;
1676 4425 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1677 4425 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1678 4425 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1679 4425 tempdcs.bombdoorcombo_l[2]=0;
1680 4425 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1681 4425 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1682 4425 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1683
1684 //right
1685
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1686 {
1687
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1688 {
1689 238950 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1690 238950 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1691 238950 }
1692 39825 }
1693
1694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1695 {
1696 if((j!=2)&&(j!=3))
1697 {
1698 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1699 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1700 }
1701 }
1702
1703 4425 tempdcs.bombdoorcombo_r[0]=0;
1704 4425 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1705 4425 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1706 4425 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1707 4425 tempdcs.bombdoorcombo_r[2]=0;
1708 4425 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1709 4425 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1710 4425 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1711
1712 int32_t k;
1713
1714
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 10306 times.
10366 for(k=0; k<door_combo_set_count; k++)
1715 {
1716
2/2
✓ Branch 0 taken 5941 times.
✓ Branch 1 taken 4365 times.
10306 if(DoorComboSets[k]==tempdcs)
1717 {
1718 4365 break;
1719 }
1720 5941 }
1721
1722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 if (k >= DoorComboSets.size())
1723 {
1724 return 0;
1725 }
1726
1727
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 4365 times.
4425 if(k==door_combo_set_count)
1728 {
1729 60 DoorComboSets[k]=tempdcs;
1730 60 DoorComboSetNames[k] = fmt::format("Door Combo Set {}", k);
1731 60 ++door_combo_set_count;
1732 60 }
1733
1734 4425 return k;
1735 /*
1736 doorcombo_u[9][4];
1737 doorcset_u[9][4];
1738 doorcombo_d[9][4];
1739 doorcset_d[9][4];
1740 doorcombo_l[9][6];
1741 doorcset_l[9][6];
1742 doorcombo_r[9][6];
1743 doorcset_r[9][6];
1744 bombdoorcombo_u[2];
1745 bombdoorcset_u[2];
1746 bombdoorcombo_d[2];
1747 bombdoorcset_d[2];
1748 bombdoorcombo_l[3];
1749 bombdoorcset_l[3];
1750 bombdoorcombo_r[3];
1751 bombdoorcset_r[3];
1752 walkthroughcombo[4];
1753 walkthroughcset[4];
1754 */
1755 22848 }
1756
1757 2924544 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1758 {
1759 2924544 byte old_cpage = old_combo_pages[map*MAPSCRS+scr];
1760 2924544 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF) + (old_cpage<<8);
1761 }
1762
1763 2924544 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1764 {
1765
1766 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1767 }
1768
1769 2924544 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1770 {
1771 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1772 }
1773
1774
1775 83 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1776 {
1777 char temp_pwd[30];
1778 83 memset(temp_pwd,0,30);
1779
1780
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 8 times.
83 if(pwdkey!=0)
1781 {
1782 75 memcpy(temp_pwd,encrypted_pwd,30);
1783 75 temp_pwd[29]=0;
1784
1785
2/2
✓ Branch 0 taken 2250 times.
✓ Branch 1 taken 75 times.
2325 for(int32_t i=0; i<30; i++)
1786 {
1787 2250 temp_pwd[i] -= pwdkey;
1788 2250 int32_t t=pwdkey>>15;
1789 2250 pwdkey = (pwdkey<<1)+t;
1790 2250 }
1791 75 }
1792
1793 83 memcpy(pwd,temp_pwd,30);
1794 83 }
1795
1796
1797 256 bool devpwd()
1798 {
1799 #ifdef _DEBUG
1800 return true;
1801 #endif
1802 #if DEVLEVEL > 3
1803 return true;
1804 #endif
1805
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio) || is_ci();
1806 }
1807 bool check_questpwd(zquestheader *Header, char *pwd)
1808 {
1809 if(devpwd())
1810 return true;
1811 if((!strcmp(pwd, (char*)clavio)))
1812 return true;
1813 cvs_MD5Context ctx;
1814 uint8_t md5sum[16];
1815
1816 cvs_MD5Init(&ctx);
1817 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
1818 cvs_MD5Final(md5sum, &ctx);
1819
1820 return (memcmp(Header->pwd_hash,md5sum,16)==0);
1821 }
1822
1823 static char const* key_exts[KEYFILE_NUMTY] = {"key", "zcheat", "zpwd"};
1824 static bool key_hashed[KEYFILE_NUMTY] = {false, true, false};
1825 static char const* key_namestr[KEYFILE_NUMTY] = {"Master","Cheat","ZPwd"};
1826
1827 static bool check_keyfile(char const* path, char const* ext, bool hashed, char const* typestr, zquestheader* Header)
1828 {
1829 char keyfilename[2048];
1830 replace_extension(keyfilename, path, ext, 2047);
1831 if(!exists(keyfilename))
1832 return false;
1833 bool ret = false;
1834
1835 char password[QSTPWD_LEN] = {0}, pwd[32] = {0};
1836 PACKFILE *fp = pack_fopen_password(keyfilename, F_READ,"");
1837 char msg[80] = {0};
1838 pfread(msg, 80, fp);
1839 if(strcmp(msg,"ZQuest Auto-Generated Quest Password Key File. DO NOT EDIT!"))
1840 {
1841 zprint2("Found %s Key File '%s' (invalid header)\n", typestr, keyfilename);
1842 pack_fclose(fp);
1843 return false;
1844 }
1845 int16_t ver;
1846 byte bld;
1847 p_igetw(&ver, fp);
1848 p_getc(&bld, fp);
1849 pfread(password, QSTPWD_LEN, fp, true);
1850 if(hashed)
1851 {
1852 char unhashed_pw[QSTPWD_LEN] = {0};
1853
1854 char hashmap = 'Z';
1855 hashmap += 'Q';
1856 hashmap += 'U';
1857 hashmap += 'E';
1858 hashmap += 'S';
1859 hashmap += 'T';
1860
1861 for ( int32_t q = 0; q < QSTPWD_LEN; ++q )
1862 unhashed_pw[q] = password[q] - hashmap;
1863
1864 ret = check_questpwd(Header, unhashed_pw);
1865 }
1866 else ret = check_questpwd(Header, password);
1867 pack_fclose(fp);
1868 zprint2("Found %s Key File '%s' (%s access)\n",
1869 typestr, keyfilename, ret ? "valid" : "invalid");
1870 return ret;
1871 }
1872
1873 bool check_keyfiles(char const* path, vector<uint> types, zquestheader* Header)
1874 {
1875 char exedir[PATH_MAX] = {0};
1876 extract_name(path, exedir, FILENAMEALL);
1877 char const* paths[] = {path, exedir};
1878 for(uint keyty : types)
1879 {
1880 if(keyty >= KEYFILE_NUMTY)
1881 continue;
1882 for(char const* p : paths)
1883 {
1884 if(check_keyfile(p, key_exts[keyty], key_hashed[keyty], key_namestr[keyty], Header))
1885 return true;
1886 }
1887 }
1888 return false;
1889 }
1890
1891 424 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
1892 {
1893 424 zprint2("\n");
1894 424 zprint2("[QUEST METADATA]\n");
1895
1/2
✓ Branch 0 taken 424 times.
✗ Branch 1 not taken.
424 if(path)
1896 424 zprint2("Path: %s\n", path);
1897
2/2
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 98 times.
424 if(tempheader.title[0])
1898 326 zprint2("Title: %s\n", tempheader.title);
1899 424 zprint2("ZC Version: %s\n", tempheader.getVerStr());
1900
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 258 times.
424 if(tempheader.new_version_id_date_day)
1901 166 zprint2("ZC Build Date: %d-%d-%d %s %s\n", tempheader.new_version_id_date_year, tempheader.new_version_id_date_month, tempheader.new_version_id_date_day, tempheader.build_timestamp, tempheader.build_timezone);
1902
2/2
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 178 times.
424 if(tempheader.version[0])
1903 246 zprint2("Qst Version: %s\n", tempheader.version);
1904
2/2
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 98 times.
424 if(tempheader.author[0])
1905 326 zprint2("Author: %s\n", tempheader.author);
1906 424 zprint2("\n");
1907 424 }
1908
1909 793 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
1910 {
1911 int32_t dummy;
1912 793 zquestheader tempheader{};
1913
2/2
✓ Branch 0 taken 781 times.
✓ Branch 1 taken 12 times.
793 tempheader.filename = Header->filename;
1914 char dummybuf[80];
1915 byte temp_map_count;
1916 byte temp_midi_flags[MIDIFLAGS_SIZE];
1917 word version;
1918 char temp_pwd[30], temp_pwd2[30];
1919 int16_t temp_pwdkey;
1920 cvs_MD5Context ctx;
1921 781 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
1922 781 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
1923
1924
1925
1926
2/4
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 781 times.
781 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
1927 {
1928 Z_message("Unable to read header string\n");
1929 return qe_invalid;
1930 }
1931
1932 // check header
1933
2/2
✓ Branch 0 taken 757 times.
✓ Branch 1 taken 24 times.
781 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
1934 {
1935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
1936 {
1937 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
1938 return qe_invalid;
1939 }
1940 24 }
1941
1942 781 int32_t templatepath_len=0;
1943
1944 781 tempheader.external_zinfo = false;
1945 781 read_zinfo = false;
1946
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 757 times.
781 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
1947 {
1948 byte padding;
1949
1950
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&padding,f))
1951 {
1952 return qe_invalid;
1953 }
1954
1955
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&tempheader.zelda_version,f))
1956 {
1957 return qe_invalid;
1958 }
1959
1960 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
1961
1962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(tempheader.zelda_version > ZELDA_VERSION)
1963 {
1964 return qe_version;
1965 }
1966
1967 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
1968
1969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
1970 {
1971 return qe_invalid;
1972 }
1973
1974
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(bad_version(tempheader.zelda_version))
1975 {
1976 return qe_obsolete;
1977 }
1978
1979
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!p_igetw(&tempheader.internal,f))
1980 {
1981 return qe_invalid;
1982 }
1983
1984
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!p_getc(&tempheader.quest_number,f))
1985 {
1986 return qe_invalid;
1987 }
1988
1989 24 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
1990
1991
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(&quest_rules[0],2,f))
1992 {
1993 return qe_invalid;
1994 }
1995
1996
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_map_count,f))
1997 {
1998 return qe_invalid;
1999 }
2000
2001 24 FFCore.quest_format[qMapCount] = temp_map_count;
2002
2003
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.old_str_count,f))
2004 {
2005 return qe_invalid;
2006 }
2007
2008
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2009 {
2010 return qe_invalid;
2011 }
2012
2013
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!pfread(temp_midi_flags,4,f))
2014 {
2015 return qe_invalid;
2016 }
2017
2018
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2019 {
2020 return qe_invalid;
2021 }
2022
2023
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(dummybuf,14,f))
2024 {
2025 return qe_invalid;
2026 }
2027
2028
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(&quest_rules[2],2,f))
2029 {
2030 return qe_invalid;
2031 }
2032
2033
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&dummybuf,f))
2034 {
2035 return qe_invalid;
2036 }
2037
2038
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.version,9,f))
2039 {
2040 return qe_invalid;
2041 }
2042
2043
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2044 {
2045 return qe_invalid;
2046 }
2047 // These fields are expected to end in null bytes!
2048 24 tempheader.title[sizeof(tempheader.title)-1] = 0;
2049
2050
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2051 {
2052 return qe_invalid;
2053 }
2054 24 tempheader.author[sizeof(tempheader.author)-1] = 0;
2055
2056
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&padding,f))
2057 {
2058 return qe_invalid;
2059 }
2060
2061
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&temp_pwdkey,f))
2062 {
2063 return qe_invalid;
2064 }
2065
2066
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(temp_pwd,30,f))
2067 {
2068 return qe_invalid;
2069 }
2070
2071 24 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2072
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Init(&ctx);
2073
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2074
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2075
2076
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2077 {
2078 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2079 // Not anymore...
2080 memset(tempheader.minver,0,17);
2081 tempheader.build=0;
2082 tempheader.use_keyfile=0;
2083 memset(tempheader.old_foo, 0, 9);
2084 }
2085 else
2086 {
2087
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.minver,9,f))
2088 {
2089 return qe_invalid;
2090 }
2091
2092
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.build,f))
2093 {
2094 return qe_invalid;
2095 }
2096
2097 24 FFCore.quest_format[vBuild] = tempheader.build;
2098
2099
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.use_keyfile,f))
2100 {
2101 return qe_invalid;
2102 }
2103
2104
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(dummybuf,9,f))
2105 {
2106 return qe_invalid;
2107 }
2108 } // starting at minver
2109
2110
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2111 {
2112 6 memset(&quest_rules[4],0,16); // word rules3..rules10
2113 6 }
2114 else
2115 {
2116
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2117 {
2118 return qe_invalid; // starting at rules3
2119 }
2120
2121
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 if(tempheader.zelda_version <= 0x190)
2122 {
2123
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 set_qr(qr_MEANPLACEDTRAPS,0);
2124 12 }
2125 }
2126
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 unpack_qrs();
2127
2128
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2129
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2130 {
2131
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2132
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,(get_qr(qr_BRKBLSHLDS_DEP)));
2133
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 set_qr(qr_BRKBLSHLDS_DEP,0);
2134 18 }
2135
2136
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2137 {
2138 6 byte *mf=temp_midi_flags;
2139
2140
3/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
6 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2141 {
2142 4 mf=(byte*)dummybuf;
2143 4 }
2144
2145
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!pfread(mf,32,f)) // read new header additions
2146 {
2147 return qe_invalid; // starting at foo2
2148 }
2149
2150
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!pfread(dummybuf,18,f)) // read new header additions
2151 {
2152 return qe_invalid; // starting at foo2
2153 }
2154 6 }
2155
2156
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
24 if((tempheader.zelda_version < 0x192)||
2157
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2158 {
2159 18 memset(tempheader.templatepath,0,2048);
2160 18 }
2161 else
2162 {
2163 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2164 {
2165 return qe_invalid;
2166 }
2167 }
2168
2169
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2170
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2171 {
2172 24 tempheader.use_keyfile=0;
2173 24 }
2174 24 }
2175 else
2176 {
2177 //section id
2178
2/4
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
757 if(!p_mgetl(&dummy,f))
2179 {
2180 return qe_invalid;
2181 }
2182
2183 //section version info
2184
2/4
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
757 if(!p_igetw(&version,f))
2185 {
2186 return qe_invalid;
2187 }
2188
2189 757 FFCore.quest_format[vHeader] = version;
2190
2191
2/4
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
757 if(!p_igetw(&dummy,f))
2192 {
2193 return qe_invalid;
2194 }
2195
2196 //section size
2197
2/4
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
757 if(!p_igetl(&dummy,f))
2198 {
2199 return qe_invalid;
2200 }
2201
2202 //finally... section data
2203
2/4
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
757 if(!p_igetw(&tempheader.zelda_version,f))
2204 {
2205 return qe_invalid;
2206 }
2207
2208 757 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2209
2210 //do some quick checking...
2211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 757 times.
757 if(tempheader.zelda_version > ZELDA_VERSION)
2212 {
2213 return qe_version;
2214 }
2215
2216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 757 times.
757 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2217 {
2218 return qe_invalid;
2219 }
2220
2221
2/4
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 757 times.
757 if(bad_version(tempheader.zelda_version))
2222 {
2223 return qe_obsolete;
2224 }
2225
2226
2/4
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
757 if(!p_getc(&tempheader.build,f))
2227 {
2228 return qe_invalid;
2229 }
2230
2231 757 FFCore.quest_format[vBuild] = tempheader.build;
2232
2233
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 698 times.
757 if(version<3)
2234 {
2235
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!pfread(temp_pwd,30,f))
2236 {
2237 return qe_invalid;
2238 }
2239
2240
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!p_igetw(&temp_pwdkey,f))
2241 {
2242 return qe_invalid;
2243 }
2244
2245 59 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2246
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Init(&ctx);
2247
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2248
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2249 59 }
2250 else
2251 {
2252
2/4
✓ Branch 0 taken 698 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 698 times.
698 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2253 {
2254 return qe_invalid;
2255 }
2256 }
2257
2258
2/4
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
757 if(!p_igetw(&tempheader.internal,f))
2259 {
2260 return qe_invalid;
2261 }
2262
2263
2/4
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
757 if(!p_getc(&tempheader.quest_number,f))
2264 {
2265 return qe_invalid;
2266 }
2267
2268 757 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2269
2270 757 size_t versz = version < 8 ? 9 : 16;
2271
2/4
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
757 if(!pfread(tempheader.version,versz,f))
2272 {
2273 return qe_invalid;
2274 }
2275
2276 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2277 //needs to be copied as char[9] or stored as a s.str
2278
2/4
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
757 if(!pfread(tempheader.minver,versz,f))
2279 {
2280 return qe_invalid;
2281 }
2282
2283 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2284
2/4
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
757 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2285 {
2286 return qe_invalid;
2287 }
2288 757 tempheader.title[sizeof(tempheader.title)-1] = 0;
2289
2290
2/4
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
757 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2291 {
2292 return qe_invalid;
2293 }
2294 757 tempheader.author[sizeof(tempheader.author)-1] = 0;
2295
2296
2/4
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
757 if(!p_getc(&tempheader.use_keyfile,f))
2297 {
2298 return qe_invalid;
2299 }
2300
2301 /*
2302 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2303 {
2304 return qe_invalid;
2305 }
2306 */
2307
2/4
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
757 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2308 {
2309 return qe_invalid;
2310 }
2311
2312
2/4
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
757 if(!pfread(&dummybuf,4,f))
2313 {
2314 return qe_invalid;
2315 }
2316
2317
2/4
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
757 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2318 {
2319 return qe_invalid;
2320 }
2321
2322
2/4
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
757 if(!pfread(dummybuf,14,f))
2323 {
2324 return qe_invalid;
2325 }
2326
2327 757 templatepath_len=sizeof(tempheader.templatepath);
2328
2329
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 59 times.
757 if(version==1)
2330 {
2331 59 templatepath_len=280;
2332 59 }
2333
2334
2/4
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
757 if(!pfread(tempheader.templatepath,templatepath_len,f))
2335 {
2336 return qe_invalid;
2337 }
2338
2339
2/4
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
757 if(!p_getc(&temp_map_count,f))
2340 {
2341 return qe_invalid;
2342 }
2343
2344
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 578 times.
757 if(version>=4)
2345 {
2346
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!p_igetl(&tempheader.version_major,f))
2347 {
2348 return qe_invalid;
2349 }
2350
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!p_igetl(&tempheader.version_minor,f))
2351 {
2352 return qe_invalid;
2353 }
2354
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!p_igetl(&tempheader.version_patch,f))
2355 {
2356 return qe_invalid;
2357 }
2358
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2359 {
2360 return qe_invalid;
2361 }
2362
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2363 {
2364 return qe_invalid;
2365 }
2366
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!p_igetl(&tempheader.new_version_id_beta,f))
2367 {
2368 return qe_invalid;
2369 }
2370
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2371 {
2372 return qe_invalid;
2373 }
2374
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!p_igetl(&tempheader.new_version_id_release,f))
2375 {
2376 return qe_invalid;
2377 }
2378
2379 // 2.55 alpha 86 incorrectly used 56 as the second version component. Fix that here.
2380
3/6
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 135 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
179 if (tempheader.version_major == 2 && tempheader.version_minor == 56 && tempheader.new_version_id_alpha == 86)
2381 tempheader.version_minor = 55;
2382
2383
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2384 {
2385 return qe_invalid;
2386 }
2387
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!p_getc(&tempheader.new_version_id_date_month,f))
2388 {
2389 return qe_invalid;
2390 }
2391
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!p_getc(&tempheader.new_version_id_date_day,f))
2392 {
2393 return qe_invalid;
2394 }
2395
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2396 {
2397 return qe_invalid;
2398 }
2399
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2400 {
2401 return qe_invalid;
2402 }
2403
2404
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!pfread(tempheader.new_version_devsig,256,f))
2405 {
2406 return qe_invalid;
2407 }
2408
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2409 strcpy(tempheader.new_version_devsig, "EmilyV99");
2410
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!pfread(tempheader.new_version_compilername,256,f))
2411 {
2412 return qe_invalid;
2413 }
2414
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!pfread(tempheader.new_version_compilerversion,256,f))
2415 {
2416 return qe_invalid;
2417 }
2418
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!pfread(tempheader.product_name,1024,f))
2419 {
2420 return qe_invalid;
2421 }
2422
2423
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!p_getc(&tempheader.compilerid,f))
2424 {
2425 return qe_invalid;
2426 }
2427
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2428 {
2429 return qe_invalid;
2430 }
2431
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2432 {
2433 return qe_invalid;
2434 }
2435
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2436 {
2437 return qe_invalid;
2438 }
2439
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2440 {
2441 return qe_invalid;
2442 }
2443
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!p_igetw(&tempheader.developerid,f))
2444 {
2445 return qe_invalid;
2446 }
2447
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 179 times.
179 if(!pfread(tempheader.made_in_module_name,1024,f))
2448 {
2449 return qe_invalid;
2450 }
2451
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 179 times.
179 if(!pfread(tempheader.build_datestamp,256,f))
2452 {
2453 return qe_invalid;
2454 }
2455
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 179 times.
179 if(!pfread(tempheader.build_timestamp,256,f))
2456 {
2457 return qe_invalid;
2458 }
2459 179 }
2460 else // <4
2461 {
2462 578 tempheader.version_major = 0;
2463 578 tempheader.version_minor = 0;
2464 578 tempheader.version_patch = 0;
2465 578 tempheader.new_version_id_fourth = 0;
2466 578 tempheader.new_version_id_alpha = 0;
2467 578 tempheader.new_version_id_beta = 0;
2468 578 tempheader.new_version_id_gamma = 0;
2469 578 tempheader.new_version_id_release = 0;
2470 578 tempheader.new_version_id_date_year = 0;
2471 578 tempheader.new_version_id_date_month = 0;
2472 578 tempheader.new_version_id_date_day = 0;
2473 578 tempheader.new_version_id_date_hour = 0;
2474 578 tempheader.new_version_id_date_minute = 0;
2475
2476 578 memset(tempheader.new_version_devsig, 0, 256);
2477 578 memset(tempheader.new_version_compilername, 0, 256);
2478 578 memset(tempheader.new_version_compilerversion, 0, 256);
2479 578 memset(tempheader.product_name, 0, 1024);
2480 578 strcpy(tempheader.product_name, "ZQuest Classic");
2481
2482 578 tempheader.compilerid = 0;
2483 578 tempheader.compilerversionnumber_first = 0;
2484 578 tempheader.compilerversionnumber_second = 0;
2485 578 tempheader.compilerversionnumber_third = 0;
2486 578 tempheader.compilerversionnumber_fourth = 0;
2487 578 tempheader.developerid = 0;
2488
2489 578 memset(tempheader.made_in_module_name, 0, 1024);
2490 578 memset(tempheader.build_datestamp, 0, 256);
2491 578 memset(tempheader.build_timestamp, 0, 256);
2492 }
2493
2494
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 578 times.
757 if ( version >= 5 )
2495 {
2496
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!pfread(tempheader.build_timezone,6,f))
2497 {
2498 return qe_invalid;
2499 }
2500 179 }
2501 else // < 5
2502 {
2503 578 memset(tempheader.build_timezone, 0, 6);
2504 }
2505
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 578 times.
757 if ( version >= 6 )
2506 {
2507 byte b;
2508
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!p_getc(&b,f))
2509 {
2510 return qe_invalid;
2511 }
2512 179 tempheader.external_zinfo = b?true:false;
2513 179 read_zinfo = true;
2514 179 }
2515
2516
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 578 times.
757 if(version >= 7)
2517 {
2518
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2519 {
2520 return qe_invalid;
2521 }
2522 179 }
2523 else
2524 {
2525 578 tempheader.new_version_is_nightly = false;
2526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 578 times.
578 if(tempheader.zelda_version < 0x255)
2527 {
2528
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 519 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 59 times.
578 switch(tempheader.zelda_version)
2529 {
2530 case 0x254:
2531 tempheader.version_major = 2;
2532 tempheader.version_minor = 54;
2533 break;
2534 case 0x250:
2535
7/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 24 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 396 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 28 times.
✓ Branch 15 taken 16 times.
519 switch(tempheader.build)
2536 {
2537 case 19:
2538 tempheader.version_major = 2;
2539 tempheader.version_minor = 50;
2540 tempheader.new_version_id_gamma = 1;
2541 break;
2542 case 20:
2543 tempheader.version_major = 2;
2544 tempheader.version_minor = 50;
2545 tempheader.new_version_id_gamma = 2;
2546 break;
2547 case 21:
2548 tempheader.version_major = 2;
2549 tempheader.version_minor = 50;
2550 tempheader.new_version_id_gamma = 3;
2551 break;
2552 case 22:
2553 tempheader.version_major = 2;
2554 tempheader.version_minor = 50;
2555 tempheader.new_version_id_gamma = 4;
2556 break;
2557 case 23:
2558 tempheader.version_major = 2;
2559 tempheader.version_minor = 50;
2560 tempheader.new_version_id_gamma = 5;
2561 break;
2562 case 24:
2563 33 tempheader.version_major = 2;
2564 33 tempheader.version_minor = 50;
2565 33 tempheader.new_version_id_release = -1;
2566 33 break;
2567 case 25:
2568 tempheader.version_major = 2;
2569 tempheader.version_minor = 50;
2570 tempheader.version_patch = 1;
2571 tempheader.new_version_id_gamma = 1;
2572 break;
2573 case 26:
2574 24 tempheader.version_major = 2;
2575 24 tempheader.version_minor = 50;
2576 24 tempheader.version_patch = 1;
2577 24 tempheader.new_version_id_gamma = 2;
2578 24 break;
2579 case 27:
2580 tempheader.version_major = 2;
2581 tempheader.version_minor = 50;
2582 tempheader.version_patch = 1;
2583 tempheader.new_version_id_gamma = 3;
2584 break;
2585 case 28:
2586 6 tempheader.version_major = 2;
2587 6 tempheader.version_minor = 50;
2588 6 tempheader.version_patch = 1;
2589 6 tempheader.new_version_id_release = -1;
2590 6 break;
2591 case 29:
2592 396 tempheader.version_major = 2;
2593 396 tempheader.version_minor = 50;
2594 396 tempheader.version_patch = 2;
2595 396 tempheader.new_version_id_release = -1;
2596 396 break;
2597 case 30:
2598 tempheader.version_major = 2;
2599 tempheader.version_minor = 50;
2600 tempheader.version_patch = 3;
2601 tempheader.new_version_id_gamma = 1;
2602 break;
2603 case 31:
2604 16 tempheader.version_major = 2;
2605 16 tempheader.version_minor = 53;
2606 16 tempheader.new_version_id_gamma = -1;
2607 16 break;
2608 case 32:
2609 28 tempheader.version_major = 2;
2610 28 tempheader.version_minor = 53;
2611 28 tempheader.new_version_id_release = -1;
2612 28 break;
2613 case 33:
2614 16 tempheader.version_major = 2;
2615 16 tempheader.version_minor = 53;
2616 16 tempheader.version_patch = 1;
2617 16 break;
2618 }
2619 519 break;
2620
2621 case 0x211:
2622 tempheader.version_major = 2;
2623 tempheader.version_minor = 11;
2624 tempheader.new_version_id_beta = tempheader.build;
2625 break;
2626 case 0x210:
2627 59 tempheader.version_major = 2;
2628 59 tempheader.version_minor = 10;
2629 59 tempheader.new_version_id_beta = tempheader.build;
2630 59 break;
2631 }
2632 578 }
2633 }
2634
2635
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 622 times.
757 if (version>=9)
2636 {
2637 135 std::string version_string;
2638
2/4
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
135 if(!p_getcstr(&version_string, f))
2639 {
2640 return qe_invalid;
2641 }
2642
2643 135 strncpy(tempheader.zelda_version_string, version_string.c_str(), sizeof(tempheader.zelda_version_string));
2644 135 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%s", version_string.c_str());
2645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
135 }
2646 else
2647 {
2648 622 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%d.%d.%d", tempheader.version_major, tempheader.version_minor, tempheader.version_patch);
2649 }
2650 }
2651
2652
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 769 times.
781 if(printmetadata)
2653 {
2654
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2655 12 }
2656
2657 //{ Version Warning
2658
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 int32_t vercmp = tempheader.compareVer();
2659
3/6
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 781 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 781 times.
✗ Branch 5 not taken.
781 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), getAlphaState());
2660
2/4
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 781 times.
✗ Branch 3 not taken.
781 int32_t avercmp = compare(tempheader.getAlphaVer(), 0);
2661
4/6
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✓ Branch 3 taken 646 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 135 times.
916 if(vercmp > 0 || (!vercmp &&
2662
2/4
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
135 (astatecmp > 0 || (!astatecmp &&
2663 135 avercmp > 0))))
2664 {
2665 bool r = true;
2666 if(loadquest_report)
2667 {
2668 enter_sys_pal();
2669 AlertDialog("Quest saved in newer version",
2670 "This quest was last saved in a newer version of ZQuest."
2671 " Attempting to load this quest may not work correctly; to"
2672 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2673 "\n\nWould you like to continue loading anyway? (Not recommended)",
2674 [&](bool ret,bool)
2675 {
2676 r = ret;
2677 }).show();
2678 exit_sys_pal();
2679 }
2680 if(!r)
2681 return qe_silenterr;
2682 }
2683
2/4
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 781 times.
✗ Branch 3 not taken.
781 else if(tempheader.compareDate() > 0)
2684 {
2685 bool r = true;
2686 if(loadquest_report)
2687 {
2688 enter_sys_pal();
2689 AlertDialog("Quest saved in newer build",
2690 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
2691 " issues loading in this build."
2692 "\n{}"
2693 "\n\nWould you like to continue loading anyway?",
2694 tempheader.getVerCmpStr()),
2695 [&](bool ret,bool)
2696 {
2697 r = ret;
2698 }).show();
2699 exit_sys_pal();
2700 }
2701 if(!r)
2702 return qe_silenterr;
2703 }
2704 //}
2705
2706 781 read_ext_zinfo = tempheader.external_zinfo;
2707
2708
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 *Header = tempheader;
2709 781 map_count=temp_map_count;
2710 781 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2711
2712
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 unpack_qrs();
2713
2714 781 return 0;
2715 805 }
2716
2717 6448 int32_t readrules(PACKFILE *f, zquestheader *Header)
2718 {
2719
2/2
✓ Branch 0 taken 6425 times.
✓ Branch 1 taken 23 times.
6448 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_rules);
2720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6448 times.
6448 if (should_skip)
2721 return 0;
2722
2723 int32_t dummy;
2724 6448 zquestheader tempheader = *Header;
2725 6448 word s_version=0;
2726 6448 dword compatrule_version=0;
2727
2728
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 6005 times.
6448 if(tempheader.zelda_version >= 0x193)
2729 {
2730 //section version info
2731
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetw(&s_version,f))
2732 {
2733 return qe_invalid;
2734 }
2735
2736 443 FFCore.quest_format[vRules] = s_version;
2737
2738
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetw(&dummy,f))
2739 {
2740 return qe_invalid;
2741 }
2742
2743
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 264 times.
443 if(s_version > 16)
2744 {
2745
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!p_igetl(&compatrule_version,f))
2746 {
2747 return qe_invalid;
2748 }
2749 179 }
2750 443 FFCore.quest_format[vCompatRule] = compatrule_version;
2751
2752 //section size
2753
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetl(&dummy,f))
2754 {
2755 return qe_invalid;
2756 }
2757
2758
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 179 times.
443 if ( s_version < 15 )
2759 {
2760 //finally... section data
2761
2/4
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 264 times.
✗ Branch 3 not taken.
264 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
2762 {
2763 return qe_invalid;
2764 }
2765 264 }
2766 else
2767 {
2768
2769
2/4
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
2770 {
2771 return qe_invalid;
2772 }
2773
2774 }
2775 443 }
2776
2777 //{ bunch of compat stuff
2778 6448 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2779
2780
2/2
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 5982 times.
6448 unpack_qrs();
2781
2782
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version<2)
2783 {
2784
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(14,0);
2785
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(27,0);
2786
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(28,0);
2787
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(29,0);
2788
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(30,0);
2789
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(32,0);
2790
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(36,0);
2791
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(49,0);
2792
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(50,0);
2793
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(51,0);
2794
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(68,0);
2795
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(75,0);
2796
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(76,0);
2797
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(98,0);
2798
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(110,0);
2799
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(113,0);
2800
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(116,0);
2801
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(102,0);
2802
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(132,0);
2803 82 }
2804
2805 //Now, do any updates...
2806
3/4
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
466 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
2807 {
2808
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
2809
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_REPLACEOPENDOORS, 1);
2810
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLDLENSORDER, 1);
2811
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOFAIRYGUYFIRES, 1);
2812
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_TRIGGERSREPEAT, 1);
2813 82 }
2814
2815
3/4
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 443 times.
466 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2816 {
2817
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_WALLFLIERS,1);
2818 23 }
2819
2820
3/4
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 443 times.
466 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
2821 {
2822
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_NOBOMBPALFLASH,1);
2823 23 }
2824
2825
3/4
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 443 times.
466 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2826 {
2827
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_NOSCROLLCONTINUE,1);
2828 23 }
2829
2830
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(tempheader.zelda_version <= 0x210)
2831 {
2832
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ARROWCLIP,1);
2833 82 }
2834
2835
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 407 times.
466 if(tempheader.zelda_version == 0x210)
2836 {
2837
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
2838
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_CMBCYCLELAYERS, 0);
2839
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
2840 59 }
2841
2842
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(tempheader.zelda_version <= 0x210)
2843 {
2844
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLDSTYLEWARP,1);
2845
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_210_WARPRETURN,1);
2846 82 }
2847
2848 //might not be correct
2849
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 443 times.
466 if(tempheader.zelda_version < 0x210)
2850 {
2851
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
2852
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLDTRIBBLES_DEP,1);
2853
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLDHOOKSHOTGRAB,1);
2854 23 }
2855
2856
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(tempheader.zelda_version < 0x211)
2857 {
2858
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
2859 82 }
2860
2861
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 461 times.
466 if((tempheader.zelda_version == 0x192 && tempheader.build <= 163) || tempheader.zelda_version < 0x192)
2862 {
2863
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 444 times.
466 set_qr(qr_192b163_WARP,1);
2864 22 }
2865
2866
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 49 times.
22 if(tempheader.zelda_version == 0x210)
2867 {
2868
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2869
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2870
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_DMGCOMBOPRI, 0);
2871 59 }
2872
2873
3/4
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 276 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
108 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
2874 {
2875
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 198 times.
276 set_qr(qr_OLDPICKUP,1);
2876 82 }
2877
2878
3/4
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
466 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
2879 {
2880
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
2881
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
2882 82 }
2883
2884
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
2885 {
2886
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HOOKSHOTDOWNBUG, 1);
2887 82 }
2888
2889
4/4
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 172 times.
466 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
2890 {
2891
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 set_qr(qr_PEAHATCLOCKVULN, 1);
2892 33 }
2893
2894
4/4
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 179 times.
466 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
2895 {
2896
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 205 times.
287 set_qr(qr_OLD_DOORREPAIR, 1);
2897 82 }
2898
2899
4/4
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 123 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 179 times.
261 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
2900 {
2901
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 246 times.
328 set_qr(qr_OLD_SECRETMONEY, 1);
2902 82 }
2903
2904
4/4
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 123 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 179 times.
261 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
2905 {
2906
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 189 times.
328 set_qr(qr_OLD_POTION_OR_HC, 1);
2907 139 }
2908
2909
4/4
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 179 times.
318 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
2910 {
2911
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 132 times.
271 set_qr(qr_OFFSCREENWEAPONS, 1);
2912 139 }
2913
2914 //Bombchu fix.
2915
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 205 times.
318 if(tempheader.zelda_version == 0x250)
2916 {
2917
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 172 times.
205 if ( tempheader.build == 24 ) //2.50.0
2918 {
2919
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 set_qr(qr_BOMBCHUSUPERBOMB, 1);
2920 33 }
2921
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 199 times.
205 if ( tempheader.build == 28 ) //2.50.1
2922 {
2923
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 set_qr(qr_BOMBCHUSUPERBOMB, 1);
2924 6 }
2925
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 123 times.
205 if ( tempheader.build == 29 ) //2.50.2
2926 {
2927
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_BOMBCHUSUPERBOMB, 0);
2928 82 }
2929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if ( tempheader.build == 30 ) //2.50.3RC1
2930 {
2931 set_qr(qr_BOMBCHUSUPERBOMB, 0);
2932 }
2933 205 }
2934
2935
4/4
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 179 times.
318 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
2936 {
2937 // qr_OFFSETEWPNCOLLISIONFIX
2938 // All 'official' quests need this disabled.
2939 // All 2.10 and lower quests need this enabled to preseve compatability.
2940 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
2941
2942 //~Gleeok
2943
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 126 times.
271 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
2944
2945 // Broke in build 695
2946
3/4
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
145 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
2947
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 set_qr(qr_BROKENSTATUES, 1);
2948 145 }
2949
11/14
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 448 times.
✓ Branch 2 taken 443 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 567 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 567 times.
✓ Branch 9 taken 5 times.
✓ Branch 10 taken 22 times.
✓ Branch 11 taken 550 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
324 if (tempheader.zelda_version <= 0x190 || (tempheader.zelda_version == 0x192 && std::string(tempheader.title).starts_with("Zelda 3000\0")))
2950 {
2951
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 set_qr(qr_COPIED_SWIM_SPRITES, 1);
2952 22 }
2953
8/8
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 277 times.
✓ Branch 3 taken 90 times.
✓ Branch 4 taken 195 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 179 times.
✓ Branch 7 taken 16 times.
572 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
2954 {
2955
2/2
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 285 times.
556 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
2956 271 }
2957
2958
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 205 times.
287 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
2959 {
2960
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLD_210_WATER, 1);
2961 82 }
2962
2963
4/6
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 179 times.
287 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
2964 {
2965
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 143 times.
144 set_qr(qr_STEP_IS_FLOAT,0);
2966 287 }
2967
2968
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if ( tempheader.zelda_version < 0x250 )
2969 {
2970
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_8WAY_SHOT_SFX_DEP, 1);
2971 82 }
2972
2973
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version < 3)
2974 {
2975
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HOLDNOSTOPMUSIC, 1);
2976
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
2977 82 }
2978
2979
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version<4)
2980 {
2981
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(10,0);
2982 82 }
2983
2984
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version<5)
2985 {
2986
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(27,0);
2987 82 }
2988
2989
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version<6)
2990 {
2991
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(46,0);
2992 82 }
2993
2994
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version<7) // January 2008
2995 {
2996
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HEARTSREQUIREDFIX,0);
2997
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_PUSHBLOCKCSETFIX,1);
2998 82 }
2999
3000
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version<8)
3001 {
3002
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(12, 0);
3003 82 }
3004 else
3005 {
3006
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 set_bit(deprecated_rules, 12, 0);
3007 }
3008
3009
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version<9) // October 2008
3010 {
3011
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOROPE2FLASH_DEP,0);
3012
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOBUBBLEFLASH_DEP,0);
3013
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_GHINI2BLINK_DEP,0);
3014
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_PHANTOMGHINI2_DEP,0);
3015 82 }
3016
3017
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version<10) // December 2008
3018 {
3019
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOCLOCKS_DEP,0);
3020
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
3021 82 }
3022
3023
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version<11) // April 2009
3024 {
3025
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SLOWENEMYANIM_DEP,0);
3026 82 }
3027
3028 // This served no purpose.
3029 // if(s_version<12) // December 2009
3030 // {
3031 // set_qr(qr_BRKBLSHLDS_DEP,0);
3032 // set_qr(qr_OLDTRIBBLES_DEP,0);
3033 // }
3034
3035 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3036
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version < 13)
3037 {
3038
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SHOPCHEAT, 1);
3039 82 }
3040
3041 // Not entirely sure this is the best place for this...
3042 //2.50.2 bitmap offset fix
3043 466 memset(extra_rules, 0, EXTRARULES_SIZE);
3044
4/4
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 179 times.
466 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3045 {
3046
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 142 times.
287 set_er(er_BITMAPOFFSET, 1);
3047
1/2
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
145 set_qr(qr_BITMAPOFFSETFIX, 1);
3048 145 }
3049 //required because quest templates also used this bit, although
3050 //it never did anything, before. -Z
3051
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 119 times.
324 if ( tempheader.zelda_version == 0x250 )
3052 {
3053
5/6
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 123 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 107 times.
205 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3054 {
3055
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 set_er(er_BITMAPOFFSET, 0);
3056
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 set_qr(qr_BITMAPOFFSETFIX, 0);
3057 98 }
3058 205 }
3059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 324 times.
324 if ( tempheader.zelda_version == 0x254 )
3060 {
3061 set_er(er_BITMAPOFFSET, 0);
3062 set_qr(qr_BITMAPOFFSETFIX, 0);
3063 }
3064
3/4
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 145 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 179 times.
324 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3065 {
3066 set_er(er_BITMAPOFFSET, 0);
3067 set_qr(qr_BITMAPOFFSETFIX, 0);
3068 }
3069 //optimise fast drawing for older versions.
3070
3/4
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 145 times.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
324 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3071 {
3072
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 95 times.
324 set_qr(qr_OLDSPRITEDRAWS, 1);
3073 287 }
3074 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3075 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3076 //older quests can set the rule by hand. We need a new qst.dat again.
3077
4/4
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 179 times.
✓ Branch 2 taken 179 times.
✓ Branch 3 taken 287 times.
287 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3078 {
3079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 358 times.
358 set_qr(qr_OLDEWPNPARENT, 1);
3080 }
3081
4/4
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 179 times.
✓ Branch 2 taken 179 times.
✓ Branch 3 taken 287 times.
287 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3082 {
3083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 358 times.
358 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3084 }
3085
4/4
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 179 times.
✓ Branch 2 taken 179 times.
✓ Branch 3 taken 287 times.
287 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3086 {
3087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 358 times.
358 set_qr(qr_OLDQUESTMISC, 1);
3088 }
3089
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if ( tempheader.zelda_version < 0x254 )
3090 {
3091
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3092
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLDEWPNPARENT, 0);
3093
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLDQUESTMISC, 0);
3094 287 }
3095
3096 //item scripts continue to run
3097
3/4
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3098 {
3099
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3100
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3101
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3102
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3103
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3104
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3105
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3106 287 }
3107
3108
3/4
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3109 {
3110
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3111 287 }
3112
3/4
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3113 {
3114
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_TRACESCRIPTIDS, 0);
3115
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3116
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3117
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PARSER_250DIVISION,1);
3118
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3119
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3120
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PARSER_FORCE_INLINE,0);
3121
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PARSER_BINARY_32BIT,0);
3122
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 278 times.
287 if ( get_qr(qr_SELECTAWPN) )
3123 {
3124
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3125 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3126 //Now they **do**, unless you disable that behaviour.
3127 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3128 //now enable the disable L/R item swap on load.
3129 9 }
3130
3131 287 }
3132
3/4
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3133 {
3134 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3135
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3136 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3137 //animations ending earlier than they should.
3138
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3139 //Enemies would ignore solidity on the top half of combos
3140
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3141 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3142
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3143 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3144
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3145 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3146
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3147 287 }
3148
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if ( tempheader.zelda_version < 0x255 )
3149 {
3150
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_NOFFCWAITDRAW, 1);
3151
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_NOITEMWAITDRAW, 1);
3152
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3153
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3154 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3155 287 }
3156
3/4
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3157 {
3158
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3159 287 }
3160
3/4
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
287 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3161 {
3162
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_OLD_PRINTF_ARGS, 1);
3163 287 }
3164
3165
3166
3/4
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3167 {
3168
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_BROKEN_RING_POWER, 1);
3169 287 }
3170
3/4
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3171 {
3172
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3173 287 }
3174
5/6
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 36 times.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3175 {
3176
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3177 287 }
3178
3/4
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
323 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3179 {
3180 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
323 if(get_qr(qr_SET_XBUTTON_ITEMS))
3182 set_qr(qr_SET_YBUTTON_ITEMS,1);
3183 287 }
3184
3/4
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3185 {
3186
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3187 287 }
3188
3/4
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3189 {
3190
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_OLD_CHEST_COLLISION,1);
3191 287 }
3192
3193
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if ( tempheader.zelda_version < 0x254 )
3194 {
3195
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3196 287 }
3197 //Sideview spikes in 2.50.0
3198
4/4
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 179 times.
287 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3199 {
3200
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 179 times.
318 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3201 139 }
3202 //more 2.50 fixes -Z
3203
4/4
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 179 times.
318 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3204 {
3205
2/2
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 66 times.
271 set_qr(qr_MELEEMAGICCOST, 0);
3206
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3207
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 set_qr(qr_OLDMIRRORCOMBOS, 1);
3208
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 set_qr(qr_BROKENBOOKCOST, 1);
3209
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 set_qr(qr_BROKENCHARINTDRAWING, 1);
3210
3211 227 }
3212
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
406 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3213 {
3214 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3215 set_qr(qr_MELEEMAGICCOST, 1);
3216 }
3217
3218
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 383 times.
406 if(tempheader.zelda_version < 0x193)
3219 {
3220
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_SHORTDGNWALK, 1);
3221 23 }
3222
3223
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 119 times.
406 if(tempheader.zelda_version < 0x255)
3224 {
3225
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLDINFMAGIC, 1);
3226 287 }
3227
3228
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 324 times.
406 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Hero out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3229 {
3230
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3231 82 }
3232
3233
3/4
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
406 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3234 {
3235
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 119 times.
406 set_qr(qr_OLD_F6,1);
3236 287 }
3237
3/4
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3238 {
3239
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3240 287 }
3241
3/4
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3242 {
3243
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3244 287 }
3245
3/4
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3246 {
3247
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3248 287 }
3249 //}
3250
3251
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3252
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3253
3254
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 2) //Old CSet2 Handling
3255
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLDCS2,1);
3256
3257
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3258
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3259
3260
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3261
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3262
3263
3/4
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 82 times.
287 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3264
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3265
3266
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3267
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3268
3269
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3270
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3271
3272
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3273
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3274
3275
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 9)
3276 {
3277 //Hardcoded BS Patras
3278
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_HARDCODED_BS_PATRA,1);
3279 //Hardcoded Patra Inner Eye offsets
3280
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3281 //Broken 'Big enemy' animation style
3282
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3283 //Broken Attribute 31/32
3284
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3285 287 }
3286
3287
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 10) //Shared candle use limits
3288
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3289
3290
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 11) //No cross-screen return points
3291
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_RESPAWN_POINTS,1);
3292
3293
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 12)
3294 {
3295 //Old fire trail duration
3296
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3297 //Old Intro String in Ganon Room Behavior
3298
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
287 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3299
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 else set_qr(qr_GANONINTRO,1);
3300 287 }
3301
3302
2/4
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 287 times.
287 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3303 set_qr(qr_ANONE_NOANIM,1);
3304
3305
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 14) //Old Bridge Combo Behavior
3306
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3307
3308
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 15) //Broken Z3 Animation
3309
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3310
3311
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3312
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3313
3314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
287 if(compatrule_version < 17)
3315 {
3316 //Old Quake/DrawYOffset behavior
3317 //set_qr(qr_OLD_DRAWOFFSET,1);
3318 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3319 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3320 287 }
3321
3322
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 18)
3323 {
3324 //Broken DrawScreen Derivative Functions
3325
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3326 //Scrolling Cancels Charge
3327
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3328 287 }
3329
3330
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3331
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3332
3333
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 20)
3334
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3335
3336
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 21)
3337 {
3338
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3339
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3340
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3341
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_BUG_NET,1);
3342
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3343 287 }
3344
3345
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 22)
3346
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3347
3348
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 23)
3349
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_HALF_MAGIC,1);
3350
3351
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 24)
3352 {
3353
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3354
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3355 287 }
3356
3357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
287 if(compatrule_version < 25)
3358 {
3359
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
287 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3360
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3361
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3362 287 }
3363
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 26)
3364 {
3365
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3366
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_POLVIRE_NO_SHADOW,1);
3367
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3368 287 }
3369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
287 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3370 {
3371
2/2
✓ Branch 0 taken 86387 times.
✓ Branch 1 taken 287 times.
86674 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3372
1/2
✓ Branch 0 taken 86387 times.
✗ Branch 1 not taken.
86387 set_qr(q,0);
3373
2/2
✓ Branch 0 taken 1435 times.
✓ Branch 1 taken 287 times.
1722 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < qr_MAX; ++q)
3374
1/2
✓ Branch 0 taken 1435 times.
✗ Branch 1 not taken.
1435 set_qr(q,0);
3375 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3376 287 }
3377
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
287 if(compatrule_version < 28)
3378
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3379
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
297 if(compatrule_version < 29)
3380
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3381
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
297 if(compatrule_version < 30)
3382 {
3383
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_DECO_2_YOFFSET,1);
3384
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_SCREENSTATE_80s_BUG,1);
3385 292 }
3386
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
297 if(compatrule_version < 31)
3387 {
3388
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3389
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3390 292 }
3391
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
297 if(compatrule_version < 32)
3392
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3393
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
297 if(compatrule_version < 33)
3394
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_NO_LIFT_SPRITE,1);
3395
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
297 if(compatrule_version < 34)
3396 {
3397
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3398
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3399
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3400
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3401 292 }
3402
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 3 times.
297 if(compatrule_version < 35)
3403 {
3404
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3405
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3406 294 }
3407
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 3 times.
297 if(compatrule_version < 36)
3408
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 set_qr(qr_OLD_SHALLOW_SFX,1);
3409
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 3 times.
297 if(compatrule_version < 37)
3410
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3411
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 3 times.
301 if(compatrule_version < 38)
3412
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3413
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 3 times.
301 if(compatrule_version < 39)
3414
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3415
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 3 times.
301 if(compatrule_version < 40)
3416
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3417
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 5 times.
301 if(compatrule_version < 41)
3418
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKENHITBY,1);
3419
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 5 times.
305 if(compatrule_version < 42)
3420
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3421
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 5 times.
305 if(compatrule_version < 43)
3422
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_OLD_BOMB_HITBOXES,1);
3423
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 5 times.
305 if(compatrule_version < 44)
3424
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3425
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 5 times.
305 if(compatrule_version < 45)
3426
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3427
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 5 times.
305 if(compatrule_version < 46)
3428
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3429
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
305 if(compatrule_version < 47)
3430 {
3431
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3432
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3433 304 }
3434
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 48)
3435
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_GUY_HANDLING,1);
3436
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 49)
3437
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3438
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 50)
3439
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_LENS_LAYEREFFECT,1);
3440
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 51)
3441
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_PUSHBLOCK_SPRITE_LAYER,1);
3442
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if (compatrule_version < 52)
3443
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_SCRIPT_VOLUME, 1);
3444
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 53)
3445 {
3446
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_SUBSCR,1);
3447
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_ITM_0_INVIS_ON_BTNS,1);
3448
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_GAUGE_TILE_LAYOUT,1);
3449 304 }
3450
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 54)
3451
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE,1);
3452
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 55)
3453
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ,1);
3454
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 56)
3455
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_BROKEN_LIGHTBEAM_HITBOX,1);
3456
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 57)
3457
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS,1);
3458
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 58)
3459
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_DMAP_INTRO_STRINGS,1);
3460
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 59)
3461
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_SCRIPT_CONTHP_IS_HEARTS,1);
3462
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 60)
3463
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_SEPARATE_BOMBABLE_TAPPING_SFX,1);
3464
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 61)
3465
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_BROKEN_BOMB_AMMO_COSTS,1);
3466
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 62)
3467
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_BROKEN_WARPEX_MUSIC,1);
3468
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 6 times.
309 if(compatrule_version < 63)
3469 {
3470
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_BROKEN_LIFTSWIM,1);
3471
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_BROKEN_GENERIC_PUSHBLOCK_LOCKING,1);
3472 305 }
3473
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 6 times.
311 if(compatrule_version < 64)
3474
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_BROKEN_FLAME_ARROW_REFLECTING,1);
3475
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 21 times.
311 if(compatrule_version < 65)
3476
1/2
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
330 set_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP,1);
3477
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 19 times.
351 if(compatrule_version < 66)
3478
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_NEWDARK_TRANS_STACKING,1);
3479
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 19 times.
351 if(compatrule_version < 67)
3480
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_OLD_HERO_WARP_RETSQUARE,1);
3481
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 19 times.
351 if(compatrule_version < 68)
3482
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_SCRIPTS_6_BIT_COLOR,1);
3483
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 19 times.
351 if(compatrule_version < 69)
3484
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_SETENEMYWEAPONSOUNDSONWPNCHANGE, 1);
3485
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 19 times.
351 if (compatrule_version < 70)
3486
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_BROKEN_CONVEYORS, 1);
3487
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 19 times.
351 if (compatrule_version < 71)
3488
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_BROKEN_PUSHBLOCK_TOP_HALF_SOLIDS, 1);
3489
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 19 times.
351 if (compatrule_version < 72)
3490
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_BROKEN_PUSHBLOCK_FLAG_CLONING, 1);
3491
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 19 times.
351 if (compatrule_version < 73)
3492 {
3493
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_OLD_LANDING_SFX, 1);
3494
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_FIRE_LEVEL_TRIGGERS_ARENT_WEAPONS, 1);
3495 332 }
3496
5/6
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 331 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 331 times.
✗ Branch 5 not taken.
351 if (compatrule_version < 74 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 9) < 0))
3497
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 331 times.
1 set_qr(qr_BROKEN_SCRIPTS_SCROLLING_HERO_POSITION, 1);
3498
5/6
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 350 times.
✓ Branch 2 taken 331 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 331 times.
✗ Branch 5 not taken.
682 if (compatrule_version < 75 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3499
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 331 times.
1 set_qr(qr_BROKEN_SCRIPTS_BITMAP_DRAW_ORIGIN, 1);
3500
5/6
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 681 times.
✓ Branch 2 taken 331 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 331 times.
✗ Branch 5 not taken.
1013 if (compatrule_version < 76 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3501
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 331 times.
1 set_qr(qr_INVERTED_DARK_COMBO_TRIGGERS, 1);
3502
2/2
✓ Branch 0 taken 349 times.
✓ Branch 1 taken 995 times.
1344 if (compatrule_version < 77)
3503
1/2
✓ Branch 0 taken 349 times.
✗ Branch 1 not taken.
349 set_qr(qr_BROKEN_ICY_FLOOR_SIDEVIEW, 1);
3504
2/2
✓ Branch 0 taken 349 times.
✓ Branch 1 taken 995 times.
1344 if (compatrule_version < 78)
3505
1/2
✓ Branch 0 taken 349 times.
✗ Branch 1 not taken.
349 set_qr(qr_SCRIPTS_SCREEN_DRAW_LIGHT_NO_OFFSET, 1);
3506
3507
2/2
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 878 times.
1344 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3508
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 179 times.
466 if (s_version < 16)
3509
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3510
3511
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 *Header = tempheader;
3512
3513 466 return 0;
3514 12430 }
3515
3516 3958803 void init_msgstr(MsgStr *str)
3517 {
3518
2/4
✓ Branch 0 taken 3958803 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3958803 times.
3958803 str->setFromLegacyEncoding("");
3519 3958803 str->nextstring=0;
3520 3958803 str->tile=0;
3521 3958803 str->cset=0;
3522 3958803 str->trans=false;
3523 3958803 str->font=font_zfont;
3524 3958803 str->y=32;
3525 3958803 str->sfx=18;
3526 3958803 str->listpos=0;
3527 3958803 str->x=24;
3528 3958803 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3529 3958803 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3530 3958803 str->hspace=0;
3531 3958803 str->vspace=0;
3532 3958803 str->stringflags=0;
3533 3958803 str->margins[up] = 8;
3534 3958803 str->margins[down] = 0;
3535 3958803 str->margins[left] = 8;
3536 3958803 str->margins[right] = 8;
3537 3958803 str->portrait_tile = 0;
3538 3958803 str->portrait_cset = 0;
3539 3958803 str->portrait_x = 0;
3540 3958803 str->portrait_y = 0;
3541 3958803 str->portrait_tw = 1;
3542 3958803 str->portrait_th = 1;
3543 3958803 str->shadow_type = 0;
3544 3958803 str->shadow_color = 0;
3545 3958803 str->drawlayer = 6;
3546 3958803 }
3547
3548 466 void init_msgstrings(int32_t start, int32_t end)
3549 {
3550
2/4
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 466 times.
466 if(end <= start || end-start > msg_strings_size)
3551 return;
3552
3553
2/2
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 3817472 times.
3817938 for(int32_t i=start; i<end; i++)
3554 {
3555 3817472 init_msgstr(&MsgStrings[i]);
3556 3817472 MsgStrings[i].listpos=i;
3557 3817472 }
3558
3559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 466 times.
466 if(start==0)
3560 {
3561
2/4
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 466 times.
466 MsgStrings[0].setFromLegacyEncoding("(None)");
3562 466 MsgStrings[0].listpos = 0;
3563 466 }
3564 466 }
3565
3566 467 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3567 {
3568
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 443 times.
467 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_strings);
3569
3570 467 MsgStr tempMsgString;
3571
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 init_msgstr(&tempMsgString);
3572
3573 467 word temp_msg_count=0;
3574 word temp_expansion[16];
3575 467 memset(temp_expansion, 0, 16*sizeof(word));
3576 467 char buf[8193] = {0};
3577
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 443 times.
467 if(Header->zelda_version < 0x193)
3578 {
3579 byte tempbyte;
3580 24 int32_t strings_to_read=0;
3581
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3582
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3583
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
3584
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3585 {
3586 18 strings_to_read=128;
3587 18 temp_msg_count=Header->old_str_count;
3588
3589 // Some sort of string count corruption seems to be common in old quests
3590
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(temp_msg_count>128)
3591 {
3592 temp_msg_count=128;
3593 }
3594 18 }
3595
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3596 {
3597 strings_to_read=255;
3598 temp_msg_count=Header->old_str_count;
3599 }
3600 else
3601 {
3602
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_igetw(&temp_msg_count,f))
3603 {
3604 return qe_invalid;
3605 }
3606
3607 6 strings_to_read=temp_msg_count;
3608
3609
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
6 if (!should_skip && temp_msg_count >= msg_strings_size)
3610 {
3611 Z_message("Reallocating string buffer...\n");
3612
3613 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3614 // return qe_nomem;
3615
3616 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3617 delete[] MsgStrings;
3618 MsgStrings = new MsgStr[MAXMSGS];
3619 msg_strings_size = MAXMSGS;
3620 for(auto q = 0; q < msg_strings_size; ++q)
3621 {
3622 MsgStrings[q].clear();
3623 }
3624 }
3625 }
3626
3627 //reset the message strings
3628
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3629
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 init_msgstrings(0,msg_strings_size);
3630
3631
2/2
✓ Branch 0 taken 2550 times.
✓ Branch 1 taken 24 times.
2574 for(int32_t x=0; x<strings_to_read; x++)
3632 {
3633
1/2
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
2550 init_msgstr(&tempMsgString);
3634 2550 tempMsgString.listpos = x;
3635
3636
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!pfread(buf,73,f))
3637 {
3638 return qe_invalid;
3639 }
3640
3641 2550 buf[74] = '\0';
3642
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 tempMsgString.setFromLegacyEncoding(buf);
3643
3644
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!p_getc(&tempbyte,f))
3645 {
3646 return qe_invalid;
3647 }
3648
3649
3/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 2304 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 246 times.
2796 if((Header->zelda_version < 0x192)||
3650
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3651 {
3652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2304 times.
2304 tempMsgString.nextstring=tempbyte?x+1:0;
3653
3654
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3655 {
3656 return qe_invalid;
3657 }
3658
3659
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3660 {
3661 return qe_invalid;
3662 }
3663 2304 }
3664 else
3665 {
3666
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!p_igetw(&tempMsgString.nextstring,f))
3667 {
3668 return qe_invalid;
3669 }
3670
3671
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!pfread(temp_expansion,32,f))
3672 {
3673 return qe_invalid;
3674 }
3675 }
3676
3677
2/2
✓ Branch 0 taken 2549 times.
✓ Branch 1 taken 1 times.
2550 if (!should_skip)
3678 {
3679
1/2
✓ Branch 0 taken 2549 times.
✗ Branch 1 not taken.
2549 MsgStrings[x] = tempMsgString;
3680 2549 }
3681 2550 }
3682 24 }
3683 else
3684 {
3685 int32_t dummy_int;
3686 word s_version;
3687
3688 //section version info
3689
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetw(&s_version,f))
3690 {
3691 return qe_invalid;
3692 }
3693
3694 443 FFCore.quest_format[vStrings] = s_version;
3695
3696
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!read_deprecated_section_cversion(f))
3697 {
3698 return qe_invalid;
3699 }
3700
3701 //section size
3702
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetl(&dummy_int,f))
3703 {
3704 return qe_invalid;
3705 }
3706
3707 //finally... section data
3708
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetw(&temp_msg_count,f))
3709 {
3710 return qe_invalid;
3711 }
3712
3713
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
443 if(temp_msg_count >= msg_strings_size && !should_skip)
3714 {
3715 Z_message("Reallocating string buffer...\n");
3716
3717 delete[] MsgStrings;
3718 MsgStrings = new MsgStr[MAXMSGS];
3719 msg_strings_size = MAXMSGS;
3720 for(auto q = 0; q < msg_strings_size; ++q)
3721 {
3722 MsgStrings[q].clear();
3723 }
3724 }
3725
3726 //reset the message strings
3727
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 179 times.
443 if(s_version < 7)
3728
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3729
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if (!should_skip)
3730
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 init_msgstrings(0,msg_strings_size);
3731
3732 443 int32_t string_length=(s_version<2)?73:145;
3733
3734
2/2
✓ Branch 0 taken 138314 times.
✓ Branch 1 taken 443 times.
138757 for(int32_t i=0; i<temp_msg_count; i++)
3735 {
3736
1/2
✓ Branch 0 taken 138314 times.
✗ Branch 1 not taken.
138314 init_msgstr(&tempMsgString);
3737 138314 tempMsgString.listpos = i;
3738
2/2
✓ Branch 0 taken 5775 times.
✓ Branch 1 taken 132539 times.
138314 if(s_version > 8)
3739 {
3740
2/4
✓ Branch 0 taken 5775 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5775 times.
✗ Branch 3 not taken.
5775 if(!p_igetl(&string_length,f))
3741 {
3742 return qe_invalid;
3743 }
3744 5775 }
3745
3746
2/4
✓ Branch 0 taken 138314 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 138314 times.
138314 if (string_length < 0 || string_length > 8193)
3747 {
3748 return qe_invalid;
3749 }
3750
3751
2/2
✓ Branch 0 taken 137762 times.
✓ Branch 1 taken 552 times.
138314 if (string_length > 0)
3752 {
3753
2/4
✓ Branch 0 taken 137762 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137762 times.
✗ Branch 3 not taken.
137762 if (!pfread(buf, string_length, f))
3754 {
3755 return qe_invalid;
3756 }
3757 137762 }
3758 else
3759 {
3760 552 buf[0] = 0;
3761 }
3762
3763
2/4
✓ Branch 0 taken 138314 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 138314 times.
✗ Branch 3 not taken.
138314 if(!p_igetw(&tempMsgString.nextstring,f))
3764 {
3765 return qe_invalid;
3766 }
3767
3768
2/2
✓ Branch 0 taken 33613 times.
✓ Branch 1 taken 104701 times.
138314 if(s_version<2)
3769 {
3770 33613 buf[72] = '\0';
3771
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33613 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33613 times.
33613 tempMsgString.setFromLegacyEncoding(buf);
3772 33613 }
3773 else
3774 {
3775 // June 2008: A bug corrupted the last 4 chars of a string.
3776 // Discard these.
3777
1/2
✓ Branch 0 taken 104701 times.
✗ Branch 1 not taken.
104701 if(s_version<3)
3778 {
3779 for(int32_t j=140; j<144; j++)
3780 {
3781 buf[j] = '\0';
3782 }
3783 }
3784
1/2
✓ Branch 0 taken 104701 times.
✗ Branch 1 not taken.
104701 if(string_length > 8192) string_length = 8192;
3785 104701 buf[string_length]='\0'; //Force-terminate
3786
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 104701 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104701 times.
104701 tempMsgString.setFromLegacyEncoding(buf);
3787
3788
2/2
✓ Branch 0 taken 5775 times.
✓ Branch 1 taken 98926 times.
104701 if ( s_version >= 6 )
3789 {
3790
2/4
✓ Branch 0 taken 5775 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5775 times.
✗ Branch 3 not taken.
5775 if(!p_igetl(&tempMsgString.tile,f))
3791 {
3792 return qe_invalid;
3793 }
3794 5775 }
3795 else
3796 {
3797
2/4
✓ Branch 0 taken 98926 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98926 times.
✗ Branch 3 not taken.
98926 if(!p_igetw(&tempMsgString.tile,f))
3798 {
3799 return qe_invalid;
3800 }
3801 }
3802
3803
2/4
✓ Branch 0 taken 104701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104701 times.
✗ Branch 3 not taken.
104701 if(!p_getc(&tempMsgString.cset,f))
3804 {
3805 return qe_invalid;
3806 }
3807
3808 byte dummy_char;
3809
3810
2/4
✓ Branch 0 taken 104701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104701 times.
✗ Branch 3 not taken.
104701 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
3811 {
3812 return qe_invalid;
3813 }
3814
3815 104701 tempMsgString.trans=dummy_char!=0;
3816
3817
2/4
✓ Branch 0 taken 104701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104701 times.
✗ Branch 3 not taken.
104701 if(!p_getc(&tempMsgString.font,f))
3818 {
3819 return qe_invalid;
3820 }
3821
3822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104701 times.
104701 if(s_version < 5)
3823 {
3824 if(!p_getc(&tempMsgString.y,f))
3825 {
3826 return qe_invalid;
3827 }
3828 }
3829 else
3830 {
3831
2/4
✓ Branch 0 taken 104701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104701 times.
✗ Branch 3 not taken.
104701 if(!p_igetw(&tempMsgString.x,f))
3832 {
3833 return qe_invalid;
3834 }
3835
3836
2/4
✓ Branch 0 taken 104701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104701 times.
✗ Branch 3 not taken.
104701 if(!p_igetw(&tempMsgString.y,f))
3837 {
3838 return qe_invalid;
3839 }
3840
3841
2/4
✓ Branch 0 taken 104701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104701 times.
✗ Branch 3 not taken.
104701 if(!p_igetw(&tempMsgString.w,f))
3842 {
3843 return qe_invalid;
3844 }
3845
3846
2/4
✓ Branch 0 taken 104701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104701 times.
✗ Branch 3 not taken.
104701 if(!p_igetw(&tempMsgString.h,f))
3847 {
3848 return qe_invalid;
3849 }
3850
3851
2/4
✓ Branch 0 taken 104701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104701 times.
✗ Branch 3 not taken.
104701 if(!p_getc(&tempMsgString.hspace,f))
3852 {
3853 return qe_invalid;
3854 }
3855
3856
2/4
✓ Branch 0 taken 104701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104701 times.
✗ Branch 3 not taken.
104701 if(!p_getc(&tempMsgString.vspace,f))
3857 {
3858 return qe_invalid;
3859 }
3860
3861
2/4
✓ Branch 0 taken 104701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104701 times.
✗ Branch 3 not taken.
104701 if(!p_getc(&tempMsgString.stringflags,f))
3862 {
3863 return qe_invalid;
3864 }
3865 }
3866
3867
2/2
✓ Branch 0 taken 98926 times.
✓ Branch 1 taken 5775 times.
104701 if(s_version >= 7)
3868 {
3869
2/2
✓ Branch 0 taken 5775 times.
✓ Branch 1 taken 23100 times.
28875 for(int32_t q = 0; q < 4; ++q)
3870 {
3871
2/4
✓ Branch 0 taken 23100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23100 times.
✗ Branch 3 not taken.
23100 if(!p_getc(&tempMsgString.margins[q],f))
3872 {
3873 return qe_invalid;
3874 }
3875 23100 }
3876
3877
2/4
✓ Branch 0 taken 5775 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5775 times.
✗ Branch 3 not taken.
5775 if(!p_igetl(&tempMsgString.portrait_tile,f))
3878 {
3879 return qe_invalid;
3880 }
3881
3882
2/4
✓ Branch 0 taken 5775 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5775 times.
✗ Branch 3 not taken.
5775 if(!p_getc(&tempMsgString.portrait_cset,f))
3883 {
3884 return qe_invalid;
3885 }
3886
3887
2/4
✓ Branch 0 taken 5775 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5775 times.
✗ Branch 3 not taken.
5775 if(!p_getc(&tempMsgString.portrait_x,f))
3888 {
3889 return qe_invalid;
3890 }
3891
3892
2/4
✓ Branch 0 taken 5775 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5775 times.
✗ Branch 3 not taken.
5775 if(!p_getc(&tempMsgString.portrait_y,f))
3893 {
3894 return qe_invalid;
3895 }
3896
3897
2/4
✓ Branch 0 taken 5775 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5775 times.
✗ Branch 3 not taken.
5775 if(!p_getc(&tempMsgString.portrait_tw,f))
3898 {
3899 return qe_invalid;
3900 }
3901
3902
2/4
✓ Branch 0 taken 5775 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5775 times.
✗ Branch 3 not taken.
5775 if(!p_getc(&tempMsgString.portrait_th,f))
3903 {
3904 return qe_invalid;
3905 }
3906 5775 }
3907
3908
2/2
✓ Branch 0 taken 5775 times.
✓ Branch 1 taken 98926 times.
104701 if(s_version >= 8)
3909 {
3910
2/4
✓ Branch 0 taken 5775 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5775 times.
✗ Branch 3 not taken.
5775 if(!p_getc(&tempMsgString.shadow_type,f))
3911 {
3912 return qe_invalid;
3913 }
3914
3915
2/4
✓ Branch 0 taken 5775 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5775 times.
✗ Branch 3 not taken.
5775 if(!p_getc(&tempMsgString.shadow_color,f))
3916 {
3917 return qe_invalid;
3918 }
3919 5775 }
3920
3921
2/2
✓ Branch 0 taken 5466 times.
✓ Branch 1 taken 99235 times.
104701 if(s_version >= 10)
3922 {
3923
2/4
✓ Branch 0 taken 5466 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5466 times.
✗ Branch 3 not taken.
5466 if(!p_getc(&tempMsgString.drawlayer,f))
3924 {
3925 return qe_invalid;
3926 }
3927 5466 }
3928
3929
2/4
✓ Branch 0 taken 104701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104701 times.
✗ Branch 3 not taken.
104701 if(!p_getc(&tempMsgString.sfx,f))
3930 {
3931 return qe_invalid;
3932 }
3933
3934
1/2
✓ Branch 0 taken 104701 times.
✗ Branch 1 not taken.
104701 if(s_version>3)
3935 {
3936
2/4
✓ Branch 0 taken 104701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104701 times.
✗ Branch 3 not taken.
104701 if(!p_igetw(&tempMsgString.listpos,f))
3937 {
3938 return qe_invalid;
3939 }
3940 104701 }
3941 }
3942
3943
1/2
✓ Branch 0 taken 138314 times.
✗ Branch 1 not taken.
138314 if (!should_skip)
3944 {
3945
1/2
✓ Branch 0 taken 138314 times.
✗ Branch 1 not taken.
138314 MsgStrings[i].copyAll(tempMsgString);
3946 138314 }
3947 138314 }
3948 }
3949
3950
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 466 times.
467 if (!should_skip)
3951 466 msg_count=temp_msg_count;
3952
3953 467 return 0;
3954 467 }
3955
3956 467 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
3957 {
3958
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 443 times.
467 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_doors);
3959
3960
3/4
✓ Branch 0 taken 449 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
473 if((Header->zelda_version < 0x192)||
3961
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 443 times.
449 ((Header->zelda_version == 0x192)&&(Header->build<158)))
3962 {
3963 18 return 0;
3964 }
3965
3966 449 word temp_door_combo_set_count=0;
3967 DoorComboSet tempDoorComboSet;
3968 word dummy_word;
3969 int32_t dummy_long;
3970 byte padding;
3971 449 int32_t s_version = 0;
3972
3973
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 448 times.
449 if (!should_skip)
3974 {
3975 448 DoorComboSets = {};
3976 448 DoorComboSetNames = {};
3977 448 }
3978
3979
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 443 times.
449 if(Header->zelda_version > 0x192)
3980 {
3981 //section version info
3982
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetw(&s_version,f))
3983 {
3984 return qe_invalid;
3985 }
3986
3987 443 FFCore.quest_format[vDoors] = s_version;
3988
3989
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetw(&dummy_word,f))
3990 {
3991 return qe_invalid;
3992 }
3993
3994 //section size
3995
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetl(&dummy_long,f))
3996 {
3997 return qe_invalid;
3998 }
3999 443 }
4000
4001 //finally... section data
4002
1/2
✓ Branch 0 taken 449 times.
✗ Branch 1 not taken.
449 if(!p_igetw(&temp_door_combo_set_count,f))
4003 {
4004 return qe_invalid;
4005 }
4006
4007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 449 times.
449 if (temp_door_combo_set_count > MAXDOORCOMBOSETS)
4008 {
4009 return qe_invalid;
4010 }
4011
4012
2/2
✓ Branch 0 taken 5279 times.
✓ Branch 1 taken 449 times.
5728 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4013 {
4014 5279 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4015
4016 //name
4017 char name[21];
4018
1/2
✓ Branch 0 taken 5279 times.
✗ Branch 1 not taken.
5279 if(!pfread(&name,sizeof(name),f))
4019 {
4020 return qe_invalid;
4021 }
4022
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5265 times.
5279 if (!should_skip)
4023 5265 DoorComboSetNames[i] = name;
4024
4025
2/2
✓ Branch 0 taken 5239 times.
✓ Branch 1 taken 40 times.
5279 if(Header->zelda_version < 0x193)
4026 {
4027
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&padding,f))
4028 {
4029 return qe_invalid;
4030 }
4031 40 }
4032
4033 //up door
4034
2/2
✓ Branch 0 taken 47511 times.
✓ Branch 1 taken 5279 times.
52790 for(int32_t j=0; j<9; j++)
4035 {
4036
2/2
✓ Branch 0 taken 190044 times.
✓ Branch 1 taken 47511 times.
237555 for(int32_t k=0; k<4; k++)
4037 {
4038
1/2
✓ Branch 0 taken 190044 times.
✗ Branch 1 not taken.
190044 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
4039 {
4040 return qe_invalid;
4041 }
4042 190044 }
4043 47511 }
4044
4045
2/2
✓ Branch 0 taken 47511 times.
✓ Branch 1 taken 5279 times.
52790 for(int32_t j=0; j<9; j++)
4046 {
4047
2/2
✓ Branch 0 taken 190044 times.
✓ Branch 1 taken 47511 times.
237555 for(int32_t k=0; k<4; k++)
4048 {
4049
1/2
✓ Branch 0 taken 190044 times.
✗ Branch 1 not taken.
190044 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4050 {
4051 return qe_invalid;
4052 }
4053 190044 }
4054 47511 }
4055
4056 //down door
4057
2/2
✓ Branch 0 taken 47511 times.
✓ Branch 1 taken 5279 times.
52790 for(int32_t j=0; j<9; j++)
4058 {
4059
2/2
✓ Branch 0 taken 190044 times.
✓ Branch 1 taken 47511 times.
237555 for(int32_t k=0; k<4; k++)
4060 {
4061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190044 times.
190044 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4062 {
4063 return qe_invalid;
4064 }
4065 190044 }
4066 47511 }
4067
4068
2/2
✓ Branch 0 taken 47511 times.
✓ Branch 1 taken 5279 times.
52790 for(int32_t j=0; j<9; j++)
4069 {
4070
2/2
✓ Branch 0 taken 190044 times.
✓ Branch 1 taken 47511 times.
237555 for(int32_t k=0; k<4; k++)
4071 {
4072
1/2
✓ Branch 0 taken 190044 times.
✗ Branch 1 not taken.
190044 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4073 {
4074 return qe_invalid;
4075 }
4076 190044 }
4077 47511 }
4078
4079 //left door
4080
2/2
✓ Branch 0 taken 47511 times.
✓ Branch 1 taken 5279 times.
52790 for(int32_t j=0; j<9; j++)
4081 {
4082
2/2
✓ Branch 0 taken 285066 times.
✓ Branch 1 taken 47511 times.
332577 for(int32_t k=0; k<6; k++)
4083 {
4084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 285066 times.
285066 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4085 {
4086 return qe_invalid;
4087 }
4088 285066 }
4089 47511 }
4090
4091
2/2
✓ Branch 0 taken 47511 times.
✓ Branch 1 taken 5279 times.
52790 for(int32_t j=0; j<9; j++)
4092 {
4093
2/2
✓ Branch 0 taken 285066 times.
✓ Branch 1 taken 47511 times.
332577 for(int32_t k=0; k<6; k++)
4094 {
4095
1/2
✓ Branch 0 taken 285066 times.
✗ Branch 1 not taken.
285066 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4096 {
4097 return qe_invalid;
4098 }
4099 285066 }
4100 47511 }
4101
4102 //right door
4103
2/2
✓ Branch 0 taken 47511 times.
✓ Branch 1 taken 5279 times.
52790 for(int32_t j=0; j<9; j++)
4104 {
4105
2/2
✓ Branch 0 taken 285066 times.
✓ Branch 1 taken 47511 times.
332577 for(int32_t k=0; k<6; k++)
4106 {
4107
1/2
✓ Branch 0 taken 285066 times.
✗ Branch 1 not taken.
285066 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4108 {
4109 return qe_invalid;
4110 }
4111 285066 }
4112 47511 }
4113
4114
2/2
✓ Branch 0 taken 47511 times.
✓ Branch 1 taken 5279 times.
52790 for(int32_t j=0; j<9; j++)
4115 {
4116
2/2
✓ Branch 0 taken 285066 times.
✓ Branch 1 taken 47511 times.
332577 for(int32_t k=0; k<6; k++)
4117 {
4118
1/2
✓ Branch 0 taken 285066 times.
✗ Branch 1 not taken.
285066 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4119 {
4120 return qe_invalid;
4121 }
4122 285066 }
4123 47511 }
4124
4125 //up bomb rubble
4126
2/2
✓ Branch 0 taken 10558 times.
✓ Branch 1 taken 5279 times.
15837 for(int32_t j=0; j<2; j++)
4127 {
4128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10558 times.
10558 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4129 {
4130 return qe_invalid;
4131 }
4132 10558 }
4133
4134
2/2
✓ Branch 0 taken 10558 times.
✓ Branch 1 taken 5279 times.
15837 for(int32_t j=0; j<2; j++)
4135 {
4136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10558 times.
10558 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4137 {
4138 return qe_invalid;
4139 }
4140 10558 }
4141
4142 //down bomb rubble
4143
2/2
✓ Branch 0 taken 10558 times.
✓ Branch 1 taken 5279 times.
15837 for(int32_t j=0; j<2; j++)
4144 {
4145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10558 times.
10558 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4146 {
4147 return qe_invalid;
4148 }
4149 10558 }
4150
4151
2/2
✓ Branch 0 taken 10558 times.
✓ Branch 1 taken 5279 times.
15837 for(int32_t j=0; j<2; j++)
4152 {
4153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10558 times.
10558 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4154 {
4155 return qe_invalid;
4156 }
4157 10558 }
4158
4159 //left bomb rubble
4160
2/2
✓ Branch 0 taken 15837 times.
✓ Branch 1 taken 5279 times.
21116 for(int32_t j=0; j<3; j++)
4161 {
4162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15837 times.
15837 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4163 {
4164 return qe_invalid;
4165 }
4166 15837 }
4167
4168
2/2
✓ Branch 0 taken 15837 times.
✓ Branch 1 taken 5279 times.
21116 for(int32_t j=0; j<3; j++)
4169 {
4170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15837 times.
15837 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4171 {
4172 return qe_invalid;
4173 }
4174 15837 }
4175
4176
2/2
✓ Branch 0 taken 5239 times.
✓ Branch 1 taken 40 times.
5279 if(Header->zelda_version < 0x193)
4177 {
4178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4179 {
4180 return qe_invalid;
4181 }
4182
4183 40 }
4184
4185 //right bomb rubble
4186
2/2
✓ Branch 0 taken 15837 times.
✓ Branch 1 taken 5279 times.
21116 for(int32_t j=0; j<3; j++)
4187 {
4188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15837 times.
15837 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4189 {
4190 return qe_invalid;
4191 }
4192 15837 }
4193
4194
2/2
✓ Branch 0 taken 15837 times.
✓ Branch 1 taken 5279 times.
21116 for(int32_t j=0; j<3; j++)
4195 {
4196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15837 times.
15837 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4197 {
4198 return qe_invalid;
4199 }
4200 15837 }
4201
4202
2/2
✓ Branch 0 taken 5239 times.
✓ Branch 1 taken 40 times.
5279 if(Header->zelda_version < 0x193)
4203 {
4204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4205 {
4206 return qe_invalid;
4207 }
4208 40 }
4209
4210 //walkthrough stuff
4211
2/2
✓ Branch 0 taken 21116 times.
✓ Branch 1 taken 5279 times.
26395 for(int32_t j=0; j<4; j++)
4212 {
4213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21116 times.
21116 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4214 {
4215 return qe_invalid;
4216 }
4217 21116 }
4218
4219
2/2
✓ Branch 0 taken 21116 times.
✓ Branch 1 taken 5279 times.
26395 for(int32_t j=0; j<4; j++)
4220 {
4221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21116 times.
21116 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4222 {
4223 return qe_invalid;
4224 }
4225 21116 }
4226
4227 //flags
4228
2/2
✓ Branch 0 taken 10558 times.
✓ Branch 1 taken 5279 times.
15837 for(int32_t j=0; j<2; j++)
4229 {
4230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10558 times.
10558 if(!p_getc(&tempDoorComboSet.flags[j],f))
4231 {
4232 return qe_invalid;
4233 }
4234 10558 }
4235
4236
2/2
✓ Branch 0 taken 5239 times.
✓ Branch 1 taken 40 times.
5279 if(Header->zelda_version < 0x193)
4237 {
4238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4239 {
4240 return qe_invalid;
4241 }
4242 40 }
4243
4244
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5265 times.
5279 if (!should_skip)
4245 5265 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4246 5279 }
4247
4248
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 448 times.
449 if (!should_skip)
4249 448 door_combo_set_count=temp_door_combo_set_count;
4250
4251 449 return 0;
4252 467 }
4253
4254 9 int32_t count_dmaps()
4255 {
4256 9 int32_t i=MAXDMAPS-1;
4257 9 bool found=false;
4258
4259
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9 times.
9 while(i>=0 && !found)
4260 {
4261
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
27 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4262
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4263
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4264 18 found=true;
4265
4266
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t j=0; j<8; j++)
4267 {
4268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(DMaps[i].grid[j]!=0)
4269
4270 found=true;
4271 72 }
4272
4273
5/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
18 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4274 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4275 27 found=true;
4276
4277
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
27 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4278
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4279
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4280
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4281 18 found=true;
4282
4283 if(!found)
4284 {
4285 i--;
4286 }
4287 }
4288
4289 9 return i+1;
4290 }
4291
4292
4293 9 int32_t count_shops(miscQdata *Misc)
4294 {
4295 9 int32_t i=NUM_SHOPS-1,j;
4296 9 bool found=false;
4297
4298
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2234 times.
✓ Branch 2 taken 2229 times.
✓ Branch 3 taken 9 times.
2238 while(i>=0 && !found)
4299 {
4300 2229 j=2;
4301
4302
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 6682 times.
✓ Branch 2 taken 6677 times.
✓ Branch 3 taken 2229 times.
8906 while(j>=0 && !found)
4303 {
4304
3/4
✓ Branch 0 taken 6672 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6672 times.
6677 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4305 {
4306 5 found=true;
4307 5 }
4308 else
4309 {
4310 6672 j--;
4311 }
4312 }
4313
4314
1/2
✓ Branch 0 taken 2229 times.
✗ Branch 1 not taken.
2229 if(Misc->shop[i].name[0]!=0)
4315 {
4316 found=true;
4317 }
4318
4319
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2224 times.
2229 if(!found)
4320 {
4321 2224 i--;
4322 2224 }
4323 }
4324
4325 9 return i+1;
4326 }
4327
4328 9 int32_t count_infos(miscQdata *Misc)
4329 {
4330 9 int32_t i=255,j;
4331 9 bool found=false;
4332
4333
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2234 times.
✓ Branch 2 taken 2229 times.
✓ Branch 3 taken 9 times.
2238 while(i>=0 && !found)
4334 {
4335 2229 j=2;
4336
4337
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 6682 times.
✓ Branch 2 taken 6677 times.
✓ Branch 3 taken 2229 times.
8906 while(j>=0 && !found)
4338 {
4339
4/4
✓ Branch 0 taken 6676 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 6672 times.
6677 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4340 {
4341 5 found=true;
4342 5 }
4343 else
4344 {
4345 6672 j--;
4346 }
4347 }
4348
4349
1/2
✓ Branch 0 taken 2229 times.
✗ Branch 1 not taken.
2229 if(Misc->info[i].name[0]!=0)
4350 {
4351 found=true;
4352 }
4353
4354
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2224 times.
2229 if(!found)
4355 {
4356 2224 i--;
4357 2224 }
4358 }
4359
4360 9 return i+1;
4361 }
4362
4363 9 int32_t count_warprings(miscQdata *Misc)
4364 {
4365 9 int32_t i=15,j;
4366 9 bool found=false;
4367
4368
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 49 times.
✓ Branch 3 taken 9 times.
58 while(i>=0 && !found)
4369 {
4370 49 j=7;
4371
4372
4/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 358 times.
✓ Branch 3 taken 49 times.
407 while(j>=0 && !found)
4373 {
4374
4/4
✓ Branch 0 taken 354 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 349 times.
358 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4375 {
4376 9 found=true;
4377 9 }
4378 else
4379 {
4380 349 j--;
4381 }
4382 }
4383
4384
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 40 times.
49 if(!found)
4385 {
4386 40 i--;
4387 40 }
4388 }
4389
4390 9 return i+1;
4391 }
4392
4393 9 int32_t count_palcycles(miscQdata *Misc)
4394 {
4395 9 int32_t i=255,j;
4396 9 bool found=false;
4397
4398
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2043 times.
✓ Branch 2 taken 2036 times.
✓ Branch 3 taken 9 times.
2045 while(i>=0 && !found)
4399 {
4400 2036 j=2;
4401
4402
4/4
✓ Branch 0 taken 2029 times.
✓ Branch 1 taken 6101 times.
✓ Branch 2 taken 6094 times.
✓ Branch 3 taken 2036 times.
8130 while(j>=0 && !found)
4403 {
4404
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 6087 times.
6094 if(Misc->cycles[i][j].count!=0)
4405 {
4406 7 found=true;
4407 7 }
4408 else
4409 {
4410 6087 j--;
4411 }
4412 }
4413
4414
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2029 times.
2036 if(!found)
4415 {
4416 2029 i--;
4417 2029 }
4418 }
4419
4420 9 return i+1;
4421 }
4422
4423 17680 void clear_screen(mapscr *temp_scr)
4424 {
4425 17680 temp_scr->zero_memory();
4426 17680 }
4427
4428 // NOTE: when modifying this, you need to also update:
4429 // readonedmap, readdmaps, and FFScript::read_dmaps
4430 // (and their associated write functions)
4431 3539 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
4432 {
4433
2/2
✓ Branch 0 taken 3515 times.
✓ Branch 1 taken 24 times.
3539 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_dmaps);
4434
4435 3539 word dmapstoread=0;
4436 3539 dmap tempDMap;
4437
4438 int32_t dummy;
4439 3539 word s_version=0;
4440 byte padding;
4441
4442 char legacy_title[22];
4443
4444
2/2
✓ Branch 0 taken 3073 times.
✓ Branch 1 taken 466 times.
3539 if (!should_skip)
4445
2/2
✓ Branch 0 taken 238592 times.
✓ Branch 1 taken 466 times.
239058 for(int32_t i=0; i<max_dmaps; i++)
4446 {
4447
1/2
✓ Branch 0 taken 238592 times.
✗ Branch 1 not taken.
238592 DMaps[start_dmap + i].clear();
4448 238592 sprintf(legacy_title," ");
4449 238592 sprintf(DMaps[start_dmap+i].intro," ");
4450 238592 DMaps[start_dmap+i].type |= dmCAVE;
4451 239058 }
4452
4453
3/4
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 3073 times.
✓ Branch 2 taken 466 times.
✗ Branch 3 not taken.
3539 if (!should_skip && s_version == 21)
4454 Regions = {};
4455
4456 3539 Header->is_z3 = false;
4457
4/4
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 443 times.
✓ Branch 3 taken 24 times.
3539 if(!Header || Header->zelda_version > 0x192)
4458 {
4459 //section version info
4460
3/4
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
3515 if(!p_igetw(&s_version,f))
4461 {
4462 return qe_invalid;
4463 }
4464 443 Header->is_z3 = s_version >= 22;
4465
4466 443 FFCore.quest_format[vDMaps] = s_version;
4467
4468
4469
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!read_deprecated_section_cversion(f))
4470 {
4471 return qe_invalid;
4472 }
4473
4474 //section size
4475
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetl(&dummy,f))
4476 {
4477 return qe_invalid;
4478 }
4479
4480 //finally... section data
4481
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetw(&dmapstoread,f))
4482 {
4483 return qe_invalid;
4484 }
4485 443 }
4486 else
4487 {
4488
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
4489
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4490 {
4491 18 dmapstoread=32;
4492 18 }
4493
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(s_version <= 4)
4494 {
4495 6 dmapstoread=OLDMAXDMAPS;
4496 6 }
4497 else
4498 {
4499 dmapstoread=MAXDMAPS;
4500 }
4501 }
4502
4503
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 384 times.
467 dmapstoread=zc_min(dmapstoread, max_dmaps);
4504
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 384 times.
467 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4505
4506
2/2
✓ Branch 0 taken 213824 times.
✓ Branch 1 taken 467 times.
214291 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4507 {
4508
1/2
✓ Branch 0 taken 213824 times.
✗ Branch 1 not taken.
213824 tempDMap.clear();
4509 213824 sprintf(legacy_title," ");
4510 213824 sprintf(tempDMap.intro," ");
4511
4512
2/4
✓ Branch 0 taken 213824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213824 times.
✗ Branch 3 not taken.
213824 if(!p_getc(&tempDMap.map,f))
4513 {
4514 return qe_invalid;
4515 }
4516
4517
2/2
✓ Branch 0 taken 17216 times.
✓ Branch 1 taken 196608 times.
213824 if(s_version <= 4)
4518 {
4519 byte tempbyte;
4520
4521
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4522 {
4523 return qe_invalid;
4524 }
4525
4526 17216 tempDMap.level=(word)tempbyte;
4527 17216 }
4528 else
4529 {
4530
2/4
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196608 times.
✗ Branch 3 not taken.
196608 if(!p_igetw(&tempDMap.level,f))
4531 {
4532 return qe_invalid;
4533 }
4534 }
4535
4536
2/4
✓ Branch 0 taken 213824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213824 times.
✗ Branch 3 not taken.
213824 if(!p_getc(&tempDMap.xoff,f))
4537 {
4538 return qe_invalid;
4539 }
4540
4541
2/4
✓ Branch 0 taken 213824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213824 times.
✗ Branch 3 not taken.
213824 if(!p_getc(&tempDMap.compass,f))
4542 {
4543 return qe_invalid;
4544 }
4545
4546
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 17216 times.
213824 if(s_version > 8) // February 2009
4547 {
4548
2/4
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196608 times.
✗ Branch 3 not taken.
196608 if(!p_igetw(&tempDMap.color,f))
4549 {
4550 return qe_invalid;
4551 }
4552 196608 }
4553 else
4554 {
4555 byte tempbyte;
4556
4557
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4558 {
4559 return qe_invalid;
4560 }
4561
4562 17216 tempDMap.color = (word)tempbyte;
4563 }
4564
4565
2/4
✓ Branch 0 taken 213824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213824 times.
✗ Branch 3 not taken.
213824 if(!p_getc(&tempDMap.midi,f))
4566 {
4567 return qe_invalid;
4568 }
4569
4570
2/4
✓ Branch 0 taken 213824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213824 times.
✗ Branch 3 not taken.
213824 if(!p_getc(&tempDMap.cont,f))
4571 {
4572 return qe_invalid;
4573 }
4574
4575
2/4
✓ Branch 0 taken 213824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213824 times.
✗ Branch 3 not taken.
213824 if(!p_getc(&tempDMap.type,f))
4576 {
4577 return qe_invalid;
4578 }
4579
4580
4/4
✓ Branch 0 taken 5920 times.
✓ Branch 1 taken 207904 times.
✓ Branch 2 taken 5876 times.
✓ Branch 3 taken 44 times.
219744 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4581
1/2
✓ Branch 0 taken 5920 times.
✗ Branch 1 not taken.
5920 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4582 5876 tempDMap.xoff = 0;
4583
4584
2/2
✓ Branch 0 taken 213824 times.
✓ Branch 1 taken 1710592 times.
1924416 for(int32_t j=0; j<8; j++)
4585 {
4586
2/4
✓ Branch 0 taken 1710592 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1710592 times.
✗ Branch 3 not taken.
1710592 if(!p_getc(&tempDMap.grid[j],f))
4587 {
4588 return qe_invalid;
4589 }
4590 1710592 }
4591
4592
5/6
✓ Branch 0 taken 213824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213248 times.
✓ Branch 3 taken 576 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 211712 times.
213824 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4593 {
4594
4/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 1975 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 127 times.
2112 if(tempDMap.level>0&&tempDMap.level<10)
4595 {
4596 127 sprintf(legacy_title,"LEVEL-%d ", tempDMap.level);
4597 127 }
4598
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 1536 times.
2112 tempDMap.title.assign(legacy_title);
4599
4600
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 558 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
576 if(i==0 && Header->zelda_version <= 0x190)
4601 {
4602
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.cont = std::max((int)tempDMap.cont - tempDMap.xoff, 0);
4603
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.compass = std::max((int)tempDMap.compass - tempDMap.xoff, 0);
4604 18 }
4605
4606 //forgotten -DD
4607
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 439 times.
576 if(tempDMap.level==0)
4608 {
4609 439 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4610 439 }
4611 576 }
4612 else
4613 {
4614
3/4
✓ Branch 0 taken 213248 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 213248 times.
✗ Branch 3 not taken.
211712 if(!p_getstr(tempDMap.name,sizeof(DMaps[0].name) - 1,f))
4615 {
4616 return qe_invalid;
4617 }
4618
4619
2/2
✓ Branch 0 taken 130304 times.
✓ Branch 1 taken 82944 times.
213248 if(s_version<20)
4620 {
4621
2/4
✓ Branch 0 taken 130304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130304 times.
✗ Branch 3 not taken.
130304 if (!p_getstr(legacy_title, sizeof(legacy_title) - 1, f))
4622 {
4623 return qe_invalid;
4624 }
4625
1/2
✓ Branch 0 taken 130304 times.
✗ Branch 1 not taken.
130304 tempDMap.title.assign(legacy_title);
4626 130304 }
4627 else
4628 {
4629
2/4
✓ Branch 0 taken 82944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82944 times.
✗ Branch 3 not taken.
82944 if (!p_getwstr(&tempDMap.title, f))
4630 {
4631 return qe_invalid;
4632 }
4633 }
4634
4635
2/4
✓ Branch 0 taken 213248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213248 times.
✗ Branch 3 not taken.
213248 if(!p_getstr(tempDMap.intro,sizeof(DMaps[0].intro)-1,f))
4636 {
4637 return qe_invalid;
4638 }
4639
4640
5/8
✓ Branch 0 taken 213248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213248 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 211712 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1536 times.
213248 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4641 {
4642 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4643 DMaps[i] = tempDMap;
4644
4645 continue;
4646 }
4647
4648
3/4
✓ Branch 0 taken 213248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 211712 times.
213248 if(Header && (Header->zelda_version < 0x193))
4649 {
4650
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4651 {
4652 return qe_invalid;
4653 }
4654 1536 }
4655
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 121600 times.
213248 if ( s_version >= 11 )
4656 {
4657
2/4
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 91648 times.
✗ Branch 3 not taken.
91648 if(!p_igetl(&tempDMap.minimap_1_tile,f))
4658 {
4659 return qe_invalid;
4660 }
4661 91648 }
4662 else
4663 {
4664
2/4
✓ Branch 0 taken 121600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121600 times.
✗ Branch 3 not taken.
121600 if(!p_igetw(&tempDMap.minimap_1_tile,f))
4665 {
4666 return qe_invalid;
4667 }
4668 }
4669
4670
2/4
✓ Branch 0 taken 213248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213248 times.
✗ Branch 3 not taken.
213248 if(!p_getc(&tempDMap.minimap_1_cset,f))
4671 {
4672 return qe_invalid;
4673 }
4674
4675
3/4
✓ Branch 0 taken 213248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 211712 times.
213248 if(Header && (Header->zelda_version < 0x193))
4676 {
4677
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4678 {
4679 return qe_invalid;
4680 }
4681 1536 }
4682
4683
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 121600 times.
213248 if ( s_version >= 11 )
4684 {
4685
2/4
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 91648 times.
✗ Branch 3 not taken.
91648 if(!p_igetl(&tempDMap.minimap_2_tile,f))
4686 {
4687 return qe_invalid;
4688 }
4689 91648 }
4690 else
4691 {
4692
2/4
✓ Branch 0 taken 121600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121600 times.
✗ Branch 3 not taken.
121600 if(!p_igetw(&tempDMap.minimap_2_tile,f))
4693 {
4694 return qe_invalid;
4695 }
4696 }
4697
2/4
✓ Branch 0 taken 213248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213248 times.
✗ Branch 3 not taken.
213248 if(!p_getc(&tempDMap.minimap_2_cset,f))
4698 {
4699 return qe_invalid;
4700 }
4701
4702
3/4
✓ Branch 0 taken 213248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 211712 times.
213248 if(Header && (Header->zelda_version < 0x193))
4703 {
4704
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4705 {
4706 return qe_invalid;
4707 }
4708 1536 }
4709
4710
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 121600 times.
213248 if ( s_version >= 11 )
4711 {
4712
2/4
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 91648 times.
✗ Branch 3 not taken.
91648 if(!p_igetl(&tempDMap.largemap_1_tile,f))
4713 {
4714 return qe_invalid;
4715 }
4716 91648 }
4717 else
4718 {
4719
2/4
✓ Branch 0 taken 121600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121600 times.
✗ Branch 3 not taken.
121600 if(!p_igetw(&tempDMap.largemap_1_tile,f))
4720 {
4721 return qe_invalid;
4722 }
4723 }
4724
4725
2/4
✓ Branch 0 taken 213248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213248 times.
✗ Branch 3 not taken.
213248 if(!p_getc(&tempDMap.largemap_1_cset,f))
4726 {
4727 return qe_invalid;
4728 }
4729
4730
3/4
✓ Branch 0 taken 213248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 211712 times.
213248 if(Header && (Header->zelda_version < 0x193))
4731 {
4732
4733
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4734 {
4735 return qe_invalid;
4736 }
4737 1536 }
4738
4739
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 121600 times.
213248 if ( s_version >= 11 )
4740 {
4741
2/4
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 91648 times.
✗ Branch 3 not taken.
91648 if(!p_igetl(&tempDMap.largemap_2_tile,f))
4742 {
4743 return qe_invalid;
4744 }
4745 91648 }
4746 else
4747 {
4748
2/4
✓ Branch 0 taken 121600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121600 times.
✗ Branch 3 not taken.
121600 if(!p_igetw(&tempDMap.largemap_2_tile,f))
4749 {
4750 return qe_invalid;
4751 }
4752 }
4753
2/4
✓ Branch 0 taken 213248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213248 times.
✗ Branch 3 not taken.
213248 if(!p_getc(&tempDMap.largemap_2_cset,f))
4754 {
4755 return qe_invalid;
4756 }
4757
4758
2/4
✓ Branch 0 taken 213248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213248 times.
✗ Branch 3 not taken.
213248 if(!p_getstr(tempDMap.tmusic,sizeof(DMaps[0].tmusic)-1,f))
4759 {
4760 return qe_invalid;
4761 }
4762 }
4763
4764
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 17216 times.
213824 if(s_version>1)
4765 {
4766
2/4
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196608 times.
✗ Branch 3 not taken.
196608 if(!p_getc(&tempDMap.tmusictrack,f))
4767 {
4768 return qe_invalid;
4769 }
4770
4771
2/4
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196608 times.
✗ Branch 3 not taken.
196608 if(!p_getc(&tempDMap.active_subscreen,f))
4772 {
4773 return qe_invalid;
4774 }
4775
4776
2/4
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196608 times.
✗ Branch 3 not taken.
196608 if(!p_getc(&tempDMap.passive_subscreen,f))
4777 {
4778 return qe_invalid;
4779 }
4780 196608 }
4781
4782
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 17216 times.
213824 if(s_version>2)
4783 {
4784 byte di[32];
4785
4786
2/4
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196608 times.
✗ Branch 3 not taken.
196608 if(!pfread(&di, 32, f)) return qe_invalid;
4787
4788
2/2
✓ Branch 0 taken 50331648 times.
✓ Branch 1 taken 196608 times.
50528256 for(int32_t j=0; j<MAXITEMS; j++)
4789 {
4790
2/2
✓ Branch 0 taken 9207 times.
✓ Branch 1 taken 50322441 times.
50331648 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4791 50322441 else tempDMap.disableditems[j]=0;
4792 50331648 }
4793 196608 }
4794
4795
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 17216 times.
213824 if(s_version >= 6)
4796 {
4797
2/4
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196608 times.
✗ Branch 3 not taken.
196608 if(!p_igetl(&tempDMap.flags,f))
4798 {
4799 return qe_invalid;
4800 }
4801 196608 }
4802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17216 times.
17216 else if(s_version>3)
4803 {
4804 char temp;
4805
4806 if(!p_getc(&temp,f))
4807 {
4808 return qe_invalid;
4809 }
4810
4811 tempDMap.flags = temp;
4812 }
4813
3/8
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8992 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17216 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4814 {
4815 8992 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4816 8992 }
4817 else
4818 8224 tempDMap.flags=0;
4819
4820
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 17216 times.
213824 if(s_version<7)
4821 {
4822
5/6
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8992 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2846 times.
✓ Branch 5 taken 6146 times.
17216 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4823 6146 tempDMap.flags|= dmfVIEWMAP;
4824 17216 }
4825
4826
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 17216 times.
213824 if(s_version<8)
4827 {
4828
4/4
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8050 times.
✓ Branch 3 taken 942 times.
17216 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4829 {
4830
1/2
✓ Branch 0 taken 8050 times.
✗ Branch 1 not taken.
8050 tempDMap.type &= ~dmDNGN;
4831 8050 tempDMap.type |= dmCAVE;
4832 8050 }
4833
2/2
✓ Branch 0 taken 6834 times.
✓ Branch 1 taken 2332 times.
9166 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4834 {
4835 2332 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4836 2332 }
4837 17216 }
4838
4839
7/8
✓ Branch 0 taken 213824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2112 times.
✓ Branch 3 taken 211712 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 576 times.
✓ Branch 6 taken 1536 times.
✓ Branch 7 taken 211712 times.
213824 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4840 213248 && (Header->zelda_version < 0x193))
4841 {
4842
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4843 {
4844 return qe_invalid;
4845 }
4846 1536 }
4847
4848
2/2
✓ Branch 0 taken 122176 times.
✓ Branch 1 taken 91648 times.
213824 if(s_version >= 10)
4849 {
4850
2/4
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 91648 times.
✗ Branch 3 not taken.
91648 if(!p_getc(&tempDMap.sideview,f))
4851 {
4852 return qe_invalid;
4853 }
4854 91648 }
4855
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 122176 times.
213824 if(s_version < 10) tempDMap.sideview = 0;
4856
4857 //Dmap Scripts
4858
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 122176 times.
213824 if(s_version >= 12)
4859 {
4860
2/4
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 91648 times.
✗ Branch 3 not taken.
91648 if(!p_igetw(&tempDMap.script,f))
4861 {
4862 return qe_invalid;
4863 }
4864
2/2
✓ Branch 0 taken 733184 times.
✓ Branch 1 taken 91648 times.
824832 for ( int32_t q = 0; q < 8; q++ )
4865 {
4866
2/4
✓ Branch 0 taken 733184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 733184 times.
✗ Branch 3 not taken.
733184 if(!p_igetl(&tempDMap.initD[q],f))
4867 {
4868 return qe_invalid;
4869 }
4870 733184 }
4871 91648 }
4872
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 122176 times.
213824 if ( s_version < 12 )
4873 {
4874 122176 tempDMap.script = 0;
4875
2/2
✓ Branch 0 taken 977408 times.
✓ Branch 1 taken 122176 times.
1099584 for ( int32_t q = 0; q < 8; q++ )
4876 {
4877 977408 tempDMap.initD[q] = 0;
4878 977408 }
4879 122176 }
4880
4881
2/2
✓ Branch 0 taken 122176 times.
✓ Branch 1 taken 91648 times.
213824 if(s_version >= 13)
4882 {
4883
2/2
✓ Branch 0 taken 733184 times.
✓ Branch 1 taken 91648 times.
824832 for ( int32_t q = 0; q < 8; q++ )
4884 {
4885
2/2
✓ Branch 0 taken 47656960 times.
✓ Branch 1 taken 733184 times.
48390144 for ( int32_t w = 0; w < 65; w++ )
4886 {
4887
2/4
✓ Branch 0 taken 47656960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47656960 times.
✗ Branch 3 not taken.
47656960 if(!p_getc(&tempDMap.initD_label[q][w],f))
4888 {
4889 return qe_invalid;
4890 }
4891 47656960 }
4892 733184 }
4893 91648 }
4894
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 122176 times.
213824 if ( s_version < 13 )
4895 {
4896 122176 tempDMap.script = 0;
4897
2/2
✓ Branch 0 taken 977408 times.
✓ Branch 1 taken 122176 times.
1099584 for ( int32_t q = 0; q < 8; q++ )
4898 {
4899
2/2
✓ Branch 0 taken 63531520 times.
✓ Branch 1 taken 977408 times.
64508928 for ( int32_t w = 0; w < 65; w++ )
4900 63531520 tempDMap.initD_label[q][w] = 0;
4901 977408 }
4902 122176 }
4903
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 122176 times.
213824 if(s_version >= 14)
4904 {
4905
2/4
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 91648 times.
✗ Branch 3 not taken.
91648 if(!p_igetw(&tempDMap.active_sub_script,f))
4906 {
4907 return qe_invalid;
4908 }
4909
2/4
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 91648 times.
✗ Branch 3 not taken.
91648 if(!p_igetw(&tempDMap.passive_sub_script,f))
4910 {
4911 return qe_invalid;
4912 }
4913
2/2
✓ Branch 0 taken 733184 times.
✓ Branch 1 taken 91648 times.
824832 for ( int32_t q = 0; q < 8; ++q )
4914 {
4915
2/4
✓ Branch 0 taken 733184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 733184 times.
✗ Branch 3 not taken.
733184 if(!p_igetl(&tempDMap.sub_initD[q],f))
4916 {
4917 return qe_invalid;
4918 }
4919 733184 }
4920
2/2
✓ Branch 0 taken 733184 times.
✓ Branch 1 taken 91648 times.
824832 for(int32_t q = 0; q < 8; ++q)
4921 {
4922
2/2
✓ Branch 0 taken 47656960 times.
✓ Branch 1 taken 733184 times.
48390144 for ( int32_t w = 0; w < 65; ++w )
4923 {
4924
2/4
✓ Branch 0 taken 47656960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47656960 times.
✗ Branch 3 not taken.
47656960 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
4925 {
4926 return qe_invalid;
4927 }
4928 47656960 }
4929 733184 }
4930 91648 }
4931 else
4932 {
4933 122176 tempDMap.active_sub_script = 0;
4934 122176 tempDMap.passive_sub_script = 0;
4935
2/2
✓ Branch 0 taken 977408 times.
✓ Branch 1 taken 122176 times.
1099584 for(int32_t q = 0; q < 8; ++q)
4936 {
4937 977408 tempDMap.sub_initD[q] = 0;
4938
2/2
✓ Branch 0 taken 63531520 times.
✓ Branch 1 taken 977408 times.
64508928 for(int32_t w = 0; w < 65; ++w)
4939 63531520 tempDMap.sub_initD_label[q][w] = 0;
4940 977408 }
4941 }
4942
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 122176 times.
213824 if(s_version >= 15)
4943 {
4944
2/4
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 91648 times.
✗ Branch 3 not taken.
91648 if(!p_igetw(&tempDMap.onmap_script,f))
4945 {
4946 return qe_invalid;
4947 }
4948
2/2
✓ Branch 0 taken 733184 times.
✓ Branch 1 taken 91648 times.
824832 for ( int32_t q = 0; q < 8; ++q )
4949 {
4950
2/4
✓ Branch 0 taken 733184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 733184 times.
✗ Branch 3 not taken.
733184 if(!p_igetl(&tempDMap.onmap_initD[q],f))
4951 {
4952 return qe_invalid;
4953 }
4954 733184 }
4955
2/2
✓ Branch 0 taken 733184 times.
✓ Branch 1 taken 91648 times.
824832 for(int32_t q = 0; q < 8; ++q)
4956 {
4957
2/2
✓ Branch 0 taken 47656960 times.
✓ Branch 1 taken 733184 times.
48390144 for ( int32_t w = 0; w < 65; ++w )
4958 {
4959
2/4
✓ Branch 0 taken 47656960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47656960 times.
✗ Branch 3 not taken.
47656960 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
4960 {
4961 return qe_invalid;
4962 }
4963 47656960 }
4964 733184 }
4965 91648 }
4966 else
4967 {
4968 122176 tempDMap.onmap_script = 0;
4969
2/2
✓ Branch 0 taken 977408 times.
✓ Branch 1 taken 122176 times.
1099584 for(int32_t q = 0; q < 8; ++q)
4970 {
4971 977408 tempDMap.onmap_initD[q] = 0;
4972
2/2
✓ Branch 0 taken 63531520 times.
✓ Branch 1 taken 977408 times.
64508928 for(int32_t w = 0; w < 65; ++w)
4973 {
4974 63531520 tempDMap.onmap_initD_label[q][w] = 0;
4975 63531520 }
4976 977408 }
4977 }
4978
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 122176 times.
213824 if(s_version >= 16)
4979 {
4980
2/4
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 91648 times.
✗ Branch 3 not taken.
91648 if(!p_igetw(&tempDMap.mirrorDMap,f))
4981 {
4982 return qe_invalid;
4983 }
4984 91648 }
4985 else
4986 {
4987 122176 tempDMap.mirrorDMap = -1;
4988 }
4989
4990 // Enhanced music loop points
4991
2/2
✓ Branch 0 taken 82944 times.
✓ Branch 1 taken 130880 times.
213824 if (s_version >= 18)
4992 {
4993
2/4
✓ Branch 0 taken 82944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82944 times.
✗ Branch 3 not taken.
82944 if (!p_igetl(&tempDMap.tmusic_loop_start, f))
4994 {
4995 return qe_invalid;
4996 }
4997
2/4
✓ Branch 0 taken 82944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82944 times.
✗ Branch 3 not taken.
82944 if (!p_igetl(&tempDMap.tmusic_loop_end, f))
4998 {
4999 return qe_invalid;
5000 }
5001
2/4
✓ Branch 0 taken 82944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82944 times.
✗ Branch 3 not taken.
82944 if (!p_igetl(&tempDMap.tmusic_xfade_in, f))
5002 {
5003 return qe_invalid;
5004 }
5005
2/4
✓ Branch 0 taken 82944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82944 times.
✗ Branch 3 not taken.
82944 if (!p_igetl(&tempDMap.tmusic_xfade_out, f))
5006 {
5007 return qe_invalid;
5008 }
5009 82944 }
5010 else
5011 {
5012 130880 tempDMap.tmusic_loop_start = 0;
5013 130880 tempDMap.tmusic_loop_end = 0;
5014 130880 tempDMap.tmusic_xfade_in = 0;
5015 130880 tempDMap.tmusic_xfade_out = 0;
5016 }
5017
5018
2/2
✓ Branch 0 taken 82944 times.
✓ Branch 1 taken 130880 times.
213824 if(s_version >= 19)
5019
2/4
✓ Branch 0 taken 82944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82944 times.
✗ Branch 3 not taken.
82944 if(!p_getc(&tempDMap.overlay_subscreen, f))
5020 return qe_invalid;
5021
5022
2/2
✓ Branch 0 taken 82944 times.
✓ Branch 1 taken 130880 times.
213824 if (s_version >= 20)
5023 {
5024
2/4
✓ Branch 0 taken 82944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82944 times.
✗ Branch 3 not taken.
82944 if (!p_igetl(&tempDMap.intro_string_id, f))
5025 return qe_invalid;
5026 82944 }
5027 else
5028 130880 tempDMap.intro_string_id = 0;
5029
5030
2/2
✓ Branch 0 taken 199488 times.
✓ Branch 1 taken 14336 times.
213824 if(s_version == 21)
5031 {
5032 static regions_data tmp_rd;
5033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14336 times.
14336 regions_data& rd = should_skip ? tmp_rd : Regions[tempDMap.map];
5034
2/2
✓ Branch 0 taken 114688 times.
✓ Branch 1 taken 14336 times.
129024 for(int32_t j=0; j<8; j++)
5035 {
5036
2/2
✓ Branch 0 taken 917504 times.
✓ Branch 1 taken 114688 times.
1032192 for(int32_t k=0; k<8; k++)
5037 {
5038
2/4
✓ Branch 0 taken 917504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 917504 times.
✗ Branch 3 not taken.
917504 if(!p_getc(&rd.region_ids[j][k],f))
5039 {
5040 return qe_invalid;
5041 }
5042 917504 }
5043 114688 }
5044 14336 }
5045
5046
2/2
✓ Branch 0 taken 213568 times.
✓ Branch 1 taken 256 times.
213824 if (!should_skip)
5047 {
5048
1/2
✓ Branch 0 taken 213568 times.
✗ Branch 1 not taken.
213568 if(loading_tileset_flags & TILESET_CLEARMAPS)
5049 tempDMap.map = 0;
5050
1/2
✓ Branch 0 taken 213568 times.
✗ Branch 1 not taken.
213568 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
5051 {
5052 tempDMap.script = 0;
5053 for(int q = 0; q < 8; ++q)
5054 tempDMap.initD[q] = 0;
5055 }
5056
1/2
✓ Branch 0 taken 213568 times.
✗ Branch 1 not taken.
213568 DMaps[i] = tempDMap;
5057 213568 }
5058 213824 }
5059
5060 467 return 0;
5061 6611 }
5062
5063 384 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5064 {
5065 //these are here to bypass compiler warnings about unused arguments
5066 384 Header=Header;
5067
5068 miscQdata temp_misc;
5069 384 word s_version=0;
5070 384 int32_t tempsize=0;
5071 word dummyw;
5072
5073 384 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5074
5075 //section version info
5076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_igetw(&s_version,f))
5077 {
5078 return qe_invalid;
5079 }
5080
5081 384 FFCore.quest_format[vColours] = s_version;
5082
5083 384 al_trace("Misc Colours section version: %d\n", s_version);
5084
5085
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!read_deprecated_section_cversion(f))
5086 {
5087 return qe_invalid;
5088 }
5089
5090
5091 //section size
5092
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetl(&tempsize,f))
5093 {
5094 return qe_invalid;
5095 }
5096
5097 //finally... section data
5098 384 readsize=0;
5099
5100
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.text,f))
5101 {
5102 return qe_invalid;
5103 }
5104
5105
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.caption,f))
5106 {
5107 return qe_invalid;
5108 }
5109
5110
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.overw_bg,f))
5111 {
5112 return qe_invalid;
5113 }
5114
5115
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5116 {
5117 return qe_invalid;
5118 }
5119
5120
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5121 {
5122 return qe_invalid;
5123 }
5124
5125
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.cave_fg,f))
5126 {
5127 return qe_invalid;
5128 }
5129
5130
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.bs_dk,f))
5131 {
5132 return qe_invalid;
5133 }
5134
5135
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.bs_goal,f))
5136 {
5137 return qe_invalid;
5138 }
5139
5140
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.compass_lt,f))
5141 {
5142 return qe_invalid;
5143 }
5144
5145
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.compass_dk,f))
5146 {
5147 return qe_invalid;
5148 }
5149
5150
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5151 {
5152 return qe_invalid;
5153 }
5154
5155
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.triframe_color,f))
5156 {
5157 return qe_invalid;
5158 }
5159
5160
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.hero_dot,f))
5161 {
5162 return qe_invalid;
5163 }
5164
5165
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5166 {
5167 return qe_invalid;
5168 }
5169
5170
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5171 {
5172 return qe_invalid;
5173 }
5174
5175
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5176 {
5177 return qe_invalid;
5178 }
5179
5180
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5181 {
5182 return qe_invalid;
5183 }
5184
5185
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5186 {
5187 return qe_invalid;
5188 }
5189
5190
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5191 {
5192 return qe_invalid;
5193 }
5194
5195
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5196 {
5197 return qe_invalid;
5198 }
5199
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 205 times.
384 if(s_version < 4)
5200 {
5201
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&dummyw,f))
5202 return qe_invalid;
5203 205 temp_misc.colors.triforce_tile = dummyw;
5204
5205
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&dummyw,f))
5206 return qe_invalid;
5207 205 temp_misc.colors.triframe_tile = dummyw;
5208
5209
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&dummyw,f))
5210 return qe_invalid;
5211 205 temp_misc.colors.overworld_map_tile = dummyw;
5212
5213
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&dummyw,f))
5214 return qe_invalid;
5215 205 temp_misc.colors.dungeon_map_tile = dummyw;
5216
5217
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&dummyw,f))
5218 return qe_invalid;
5219 205 temp_misc.colors.blueframe_tile = dummyw;
5220
5221
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&dummyw,f))
5222 return qe_invalid;
5223 205 temp_misc.colors.HCpieces_tile = dummyw;
5224 205 }
5225
5226
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5227 {
5228 return qe_invalid;
5229 }
5230
5231
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5232 {
5233 return qe_invalid;
5234 }
5235
5236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(s_version < 2)
5237 {
5238 temp_misc.colors.msgtext = 0x01;
5239 }
5240 else
5241 {
5242
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.msgtext, f))
5243 {
5244 return qe_invalid;
5245 }
5246 }
5247
5248
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 179 times.
384 if ( s_version >= 3 ) //expanded tile pages to 825
5249 {
5250
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5251 {
5252 return qe_invalid;
5253 }
5254
5255
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5256 {
5257 return qe_invalid;
5258 }
5259
5260
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5261 {
5262 return qe_invalid;
5263 }
5264
5265
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5266 {
5267 return qe_invalid;
5268 }
5269
5270
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5271 {
5272 return qe_invalid;
5273 }
5274
5275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 179 times.
179 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5276 {
5277 return qe_invalid;
5278 }
5279 179 }
5280
5281 384 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5282
5283 384 return 0;
5284 384 }
5285
5286 384 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5287 {
5288 miscQdata temp_misc;
5289 384 word s_version=0;
5290 byte icons;
5291 384 int32_t tempsize=0;
5292
5293 384 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5294
5295 //section version info
5296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_igetw(&s_version,f))
5297 {
5298 return qe_invalid;
5299 }
5300
5301 384 FFCore.quest_format[vIcons] = s_version;
5302
5303
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!read_deprecated_section_cversion(f))
5304 {
5305 return qe_invalid;
5306 }
5307
5308
5309 //section size
5310
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetl(&tempsize,f))
5311 {
5312 return qe_invalid;
5313 }
5314
5315 //finally... section data
5316 384 readsize=0;
5317
5318 384 icons=4;
5319
5320
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 205 times.
384 if ( s_version >= 10 )
5321 {
5322
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t i=0; i<icons; i++)
5323 {
5324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_igetl(&temp_misc.icons[i],f))
5325 {
5326 return qe_invalid;
5327 }
5328 716 }
5329 179 }
5330 else
5331 {
5332
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<icons; i++)
5333 {
5334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 820 times.
820 if(!p_igetw(&temp_misc.icons[i],f))
5335 {
5336 return qe_invalid;
5337 }
5338 820 }
5339 }
5340
5341 384 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5342
5343 384 return 0;
5344 384 }
5345
5346 781 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5347 {
5348
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 757 times.
781 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_misc);
5349
5350 781 word maxinfos=256;
5351 781 word maxshops=256;
5352 781 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5353 781 word ponds=16, pondsize=72, expansionsize=98*2;
5354 byte tempbyte, padding;
5355 miscQdata temp_misc;
5356 781 word s_version=0;
5357 word swaptmp;
5358 781 int32_t tempsize=0;
5359
5360 781 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5361
5362
2/2
✓ Branch 0 taken 199936 times.
✓ Branch 1 taken 781 times.
200717 for(int32_t i=0; i<maxshops; ++i)
5363 {
5364 199936 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5365 199936 }
5366
5367
2/2
✓ Branch 0 taken 199936 times.
✓ Branch 1 taken 781 times.
200717 for(int32_t i=0; i<maxinfos; ++i)
5368 {
5369 199936 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5370 199936 }
5371
5372 781 memset(&temp_misc.warp, 0, sizeof(temp_misc.warp));
5373
5374
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 757 times.
781 if(Header->zelda_version > 0x192)
5375 {
5376 //section version info
5377
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 if(!p_igetw(&s_version,f))
5378 {
5379 return qe_invalid;
5380 }
5381
5382 757 FFCore.quest_format[vMisc] = s_version;
5383
5384
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 if(!read_deprecated_section_cversion(f))
5385 {
5386 return qe_invalid;
5387 }
5388
5389
5390 //section size
5391
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 if(!p_igetl(&tempsize,f))
5392 {
5393 return qe_invalid;
5394 }
5395 757 }
5396
5397 //finally... section data
5398 781 readsize=0;
5399
5400 //shops
5401
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 757 times.
781 if(Header->zelda_version > 0x192)
5402 {
5403
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 if(!p_igetw(&shops,f))
5404 {
5405 return qe_invalid;
5406 }
5407 757 }
5408
5409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 781 times.
781 if (shops > NUM_SHOPS)
5410 {
5411 return qe_invalid;
5412 }
5413
5414
2/2
✓ Branch 0 taken 10718 times.
✓ Branch 1 taken 781 times.
11499 for(int32_t i=0; i<shops; i++)
5415 {
5416
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 9518 times.
10718 if(s_version > 6)
5417 {
5418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9518 times.
9518 if(!p_getstr(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name)-1,f))
5419 {
5420 return qe_invalid;
5421 }
5422 9518 }
5423
5424
2/2
✓ Branch 0 taken 32154 times.
✓ Branch 1 taken 10718 times.
42872 for(int32_t j=0; j<3; j++)
5425 {
5426
1/2
✓ Branch 0 taken 32154 times.
✗ Branch 1 not taken.
32154 if(!p_getc(&temp_misc.shop[i].item[j],f))
5427 {
5428 return qe_invalid;
5429 }
5430
5431
2/2
✓ Branch 0 taken 28554 times.
✓ Branch 1 taken 3600 times.
32154 if(s_version < 4)
5432 {
5433 3600 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5434 3600 }
5435 32154 }
5436
5437
2/2
✓ Branch 0 taken 10334 times.
✓ Branch 1 taken 384 times.
10718 if(Header->zelda_version < 0x193)
5438 {
5439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_getc(&tempbyte,f))
5440 {
5441 return qe_invalid;
5442 }
5443 384 }
5444
5445
2/2
✓ Branch 0 taken 32154 times.
✓ Branch 1 taken 10718 times.
42872 for(int32_t j=0; j<3; j++)
5446 {
5447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32154 times.
32154 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5448 {
5449 return qe_invalid;
5450 }
5451 32154 }
5452
5453
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 9518 times.
10718 if(s_version > 3)
5454 {
5455
2/2
✓ Branch 0 taken 28554 times.
✓ Branch 1 taken 9518 times.
38072 for(int32_t j=0; j<3; j++)
5456 {
5457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28554 times.
28554 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5458 return qe_invalid;
5459 28554 }
5460 9518 }
5461
5462 /*
5463 if(s_version < 8)
5464 {
5465 for(int32_t j=0; j<3; j++)
5466 {
5467 (&temp_misc.shop[i].str[j])=0; //initialise.
5468 }
5469 }
5470 */
5471 10718 }
5472
5473 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5474
2/2
✓ Branch 0 taken 199936 times.
✓ Branch 1 taken 781 times.
200717 for(int32_t i=0; i<maxshops; ++i)
5475 {
5476
2/2
✓ Branch 0 taken 399872 times.
✓ Branch 1 taken 199936 times.
599808 for(int32_t j=0; j<3-1; j++)
5477 {
5478
2/2
✓ Branch 0 taken 599808 times.
✓ Branch 1 taken 399872 times.
999680 for(int32_t k=0; k<2-j; k++)
5479 {
5480
2/2
✓ Branch 0 taken 23275 times.
✓ Branch 1 taken 576533 times.
599808 if(temp_misc.shop[i].hasitem[k]==0)
5481 {
5482 576533 swaptmp = temp_misc.shop[i].item[k];
5483 576533 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5484 576533 temp_misc.shop[i].item[k+1] = swaptmp;
5485 576533 swaptmp = temp_misc.shop[i].price[k];
5486 576533 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5487 576533 temp_misc.shop[i].price[k+1] = swaptmp;
5488 576533 swaptmp = temp_misc.shop[i].hasitem[k];
5489 576533 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5490 576533 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5491 576533 }
5492 599808 }
5493 399872 }
5494 199936 }
5495
5496 //infos
5497
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 757 times.
781 if(Header->zelda_version > 0x192)
5498 {
5499
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 if(!p_igetw(&infos,f))
5500 {
5501 return qe_invalid;
5502 }
5503 757 }
5504
5505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 781 times.
781 if (infos > NUM_INFOS)
5506 {
5507 return qe_invalid;
5508 }
5509
5510
5511
2/2
✓ Branch 0 taken 10024 times.
✓ Branch 1 taken 781 times.
10805 for(int32_t i=0; i<infos; i++)
5512 {
5513
2/2
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 9263 times.
10024 if(s_version > 6)
5514 {
5515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9263 times.
9263 if(!p_getstr(temp_misc.info[i].name,sizeof(temp_misc.info[i].name)-1,f))
5516 {
5517 return qe_invalid;
5518 }
5519 9263 }
5520
5521
2/2
✓ Branch 0 taken 30072 times.
✓ Branch 1 taken 10024 times.
40096 for(int32_t j=0; j<3; j++)
5522 {
5523
3/4
✓ Branch 0 taken 29208 times.
✓ Branch 1 taken 864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 288 times.
30360 if((Header->zelda_version < 0x192)||
5524
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 28920 times.
29208 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5525 {
5526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 864 times.
864 if(!p_getc(&tempbyte,f))
5527 {
5528 return qe_invalid;
5529 }
5530
5531 864 temp_misc.info[i].str[j]=tempbyte;
5532 864 }
5533 else
5534 {
5535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29208 times.
29208 if(!p_igetw(&temp_misc.info[i].str[j],f))
5536 {
5537 return qe_invalid;
5538 }
5539 }
5540 30072 }
5541
5542
2/2
✓ Branch 0 taken 9640 times.
✓ Branch 1 taken 384 times.
10024 if(Header->zelda_version < 0x193)
5543 {
5544
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&tempbyte,f))
5545 {
5546 return qe_invalid;
5547 }
5548 384 }
5549
5550
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 9928 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
10024 if((Header->zelda_version == 0x192)&&(Header->build>145))
5551 {
5552
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&padding,f))
5553 {
5554 return qe_invalid;
5555 }
5556 96 }
5557
5558
2/2
✓ Branch 0 taken 30072 times.
✓ Branch 1 taken 10024 times.
40096 for(int32_t j=0; j<3; j++)
5559 {
5560
1/2
✓ Branch 0 taken 30072 times.
✗ Branch 1 not taken.
30072 if(!p_igetw(&temp_misc.info[i].price[j],f))
5561 {
5562 return qe_invalid;
5563 }
5564 30072 }
5565 10024 }
5566
5567 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5568
2/2
✓ Branch 0 taken 199936 times.
✓ Branch 1 taken 781 times.
200717 for(int32_t i=0; i<maxinfos; ++i)
5569 {
5570
2/2
✓ Branch 0 taken 399872 times.
✓ Branch 1 taken 199936 times.
599808 for(int32_t j=0; j<3-1; j++)
5571 {
5572
2/2
✓ Branch 0 taken 599808 times.
✓ Branch 1 taken 399872 times.
999680 for(int32_t k=0; k<2-j; k++)
5573 {
5574
2/2
✓ Branch 0 taken 11356 times.
✓ Branch 1 taken 588452 times.
599808 if(temp_misc.info[i].str[k]==0)
5575 {
5576 588452 swaptmp = temp_misc.info[i].str[k];
5577 588452 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5578 588452 temp_misc.info[i].str[k+1] = swaptmp;
5579 588452 swaptmp = temp_misc.info[i].price[k];
5580 588452 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5581 588452 temp_misc.info[i].price[k+1] = swaptmp;
5582 588452 }
5583 599808 }
5584 399872 }
5585 199936 }
5586
5587
5588 //warp rings
5589
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 698 times.
781 if(s_version > 5)
5590 698 warprings++;
5591
5592
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 757 times.
781 if(Header->zelda_version > 0x192)
5593 {
5594
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 if(!p_igetw(&warprings,f))
5595 {
5596 return qe_invalid;
5597 }
5598
5599
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 430 times.
757 if (warprings > NUM_WARP_RINGS)
5600 {
5601 // return qe_invalid;
5602 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5603 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5604 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5605 430 }
5606 757 }
5607
5608
2/2
✓ Branch 0 taken 8178 times.
✓ Branch 1 taken 781 times.
8959 for(int32_t i=0; i<warprings; i++)
5609 {
5610 // See above comment on the `warprings` range check.
5611 8178 bool keepdata = i < NUM_WARP_RINGS;
5612
5613
2/2
✓ Branch 0 taken 72482 times.
✓ Branch 1 taken 8178 times.
80660 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5614 {
5615
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 63522 times.
72482 if(s_version <= 3)
5616 {
5617
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_getc(&tempbyte,f))
5618 {
5619 return qe_invalid;
5620 }
5621
5622
2/2
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 5768 times.
8960 if (keepdata)
5623 5768 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5624 8960 }
5625 else
5626 {
5627 word tempword;
5628
1/2
✓ Branch 0 taken 63522 times.
✗ Branch 1 not taken.
63522 if(!p_igetw(&tempword,f))
5629 {
5630 return qe_invalid;
5631 }
5632
5633
2/2
✓ Branch 0 taken 7281 times.
✓ Branch 1 taken 56241 times.
63522 if (keepdata)
5634 56241 temp_misc.warp[i].dmap[j] = tempword;
5635 }
5636 72482 }
5637
5638
2/2
✓ Branch 0 taken 72482 times.
✓ Branch 1 taken 8178 times.
80660 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5639 {
5640
1/2
✓ Branch 0 taken 72482 times.
✗ Branch 1 not taken.
72482 if(!p_getc(&tempbyte,f))
5641 {
5642 return qe_invalid;
5643 }
5644
2/2
✓ Branch 0 taken 10473 times.
✓ Branch 1 taken 62009 times.
72482 if (keepdata)
5645 62009 temp_misc.warp[i].scr[j] = tempbyte;
5646 72482 }
5647
5648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8178 times.
8178 if(!p_getc(&tempbyte,f))
5649 {
5650 return qe_invalid;
5651 }
5652
2/2
✓ Branch 0 taken 1208 times.
✓ Branch 1 taken 6970 times.
8178 if (keepdata)
5653 6970 temp_misc.warp[i].size = tempbyte;
5654
5655
2/2
✓ Branch 0 taken 7986 times.
✓ Branch 1 taken 192 times.
8178 if(Header->zelda_version < 0x193)
5656 {
5657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5658 {
5659 return qe_invalid;
5660 }
5661 192 }
5662 8178 }
5663
5664 //palette cycles
5665
2/2
✓ Branch 0 taken 757 times.
✓ Branch 1 taken 24 times.
781 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5666 {
5667
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(int32_t i=0; i<256; i++)
5668 {
5669
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 6144 times.
24576 for(int32_t j=0; j<3; j++)
5670 {
5671 18432 temp_misc.cycles[i][j].first=0;
5672 18432 temp_misc.cycles[i][j].count=0;
5673 18432 temp_misc.cycles[i][j].speed=0;
5674 18432 }
5675 6144 }
5676
5677
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
5678
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5679 {
5680 18 palcycles=16;
5681 18 }
5682
5683
2/2
✓ Branch 0 taken 1824 times.
✓ Branch 1 taken 24 times.
1848 for(int32_t i=0; i<palcycles; i++)
5684 {
5685
2/2
✓ Branch 0 taken 5472 times.
✓ Branch 1 taken 1824 times.
7296 for(int32_t j=0; j<3; j++)
5686 {
5687
1/2
✓ Branch 0 taken 5472 times.
✗ Branch 1 not taken.
5472 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5688 {
5689 return qe_invalid;
5690 }
5691
5692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5693 {
5694 return qe_invalid;
5695 }
5696
5697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5698 {
5699 return qe_invalid;
5700 }
5701 5472 }
5702 1824 }
5703 24 }
5704
5705 //Wind warps are now just another warp ring.
5706
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 83 times.
781 if(s_version <= 5)
5707 {
5708
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 59 times.
83 if(Header->zelda_version > 0x192)
5709 {
5710
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&windwarps,f))
5711 {
5712 return qe_invalid;
5713 }
5714 59 }
5715
5716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if (windwarps > NUM_WARP_RINGS)
5717 {
5718 return qe_invalid;
5719 }
5720
5721
2/2
✓ Branch 0 taken 665 times.
✓ Branch 1 taken 83 times.
748 for(int32_t i=0; i<windwarps; i++)
5722 {
5723
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version <= 3)
5724 {
5725
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&tempbyte,f))
5726 {
5727 return qe_invalid;
5728 }
5729
5730 665 temp_misc.warp[8].dmap[i]=tempbyte;
5731 665 }
5732 else
5733 {
5734 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5735 {
5736 return qe_invalid;
5737 }
5738 }
5739
5740
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5741 {
5742 return qe_invalid;
5743 }
5744
5745 665 temp_misc.warp[8].size = 9;
5746
5747
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version == 5)
5748 {
5749 if(!p_getc(&tempbyte,f))
5750 {
5751 return qe_invalid;
5752 }
5753 }
5754 665 }
5755 83 }
5756
5757
5758 //triforce pieces
5759
2/2
✓ Branch 0 taken 6248 times.
✓ Branch 1 taken 781 times.
7029 for(int32_t i=0; i<triforces; i++)
5760 {
5761
1/2
✓ Branch 0 taken 6248 times.
✗ Branch 1 not taken.
6248 if(!p_getc(&temp_misc.triforce[i],f))
5762 {
5763 return qe_invalid;
5764 }
5765 6248 }
5766
5767 //misc color data
5768
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 83 times.
781 if(s_version<3)
5769 {
5770
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.text,f))
5771 {
5772 return qe_invalid;
5773 }
5774
5775
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.caption,f))
5776 {
5777 return qe_invalid;
5778 }
5779
5780
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overw_bg,f))
5781 {
5782 return qe_invalid;
5783 }
5784
5785
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5786 {
5787 return qe_invalid;
5788 }
5789
5790
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5791 {
5792 return qe_invalid;
5793 }
5794
5795
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.cave_fg,f))
5796 {
5797 return qe_invalid;
5798 }
5799
5800
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_dk,f))
5801 {
5802 return qe_invalid;
5803 }
5804
5805
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_goal,f))
5806 {
5807 return qe_invalid;
5808 }
5809
5810
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_lt,f))
5811 {
5812 return qe_invalid;
5813 }
5814
5815
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_dk,f))
5816 {
5817 return qe_invalid;
5818 }
5819
5820
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5821 {
5822 return qe_invalid;
5823 }
5824
5825
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_color,f))
5826 {
5827 return qe_invalid;
5828 }
5829
5830
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.hero_dot,f))
5831 {
5832 return qe_invalid;
5833 }
5834
5835
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5836 {
5837 return qe_invalid;
5838 }
5839
5840
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5841 {
5842 return qe_invalid;
5843 }
5844
5845
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5846 {
5847 return qe_invalid;
5848 }
5849
5850
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5851 {
5852 return qe_invalid;
5853 }
5854
5855
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5856 {
5857 return qe_invalid;
5858 }
5859
5860
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5861 {
5862 return qe_invalid;
5863 }
5864
5865
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5866 {
5867 return qe_invalid;
5868 }
5869
5870
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
5871 {
5872 return qe_invalid;
5873 }
5874
5875
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
5876 {
5877 return qe_invalid;
5878 }
5879
5880
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
5881 {
5882 return qe_invalid;
5883 }
5884
5885
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
5886 {
5887 return qe_invalid;
5888 }
5889
5890
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
5891 {
5892 return qe_invalid;
5893 }
5894
5895
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
5896 {
5897 return qe_invalid;
5898 }
5899
5900
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5901 {
5902 return qe_invalid;
5903 }
5904
5905 83 temp_misc.colors.msgtext = 0x01;
5906
5907
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 24 times.
83 if(Header->zelda_version < 0x193)
5908 {
5909
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 24 times.
192 for(int32_t i=0; i<7; i++)
5910 {
5911
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(!p_getc(&tempbyte,f))
5912 {
5913 return qe_invalid;
5914 }
5915 168 }
5916 24 }
5917
5918
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
83 if((Header->zelda_version == 0x192)&&(Header->build>145))
5919 {
5920
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<256; i++)
5921 {
5922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if(!p_getc(&tempbyte,f))
5923 {
5924 return qe_invalid;
5925 }
5926 1536 }
5927 6 }
5928
5929
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(s_version>1)
5930 {
5931 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5932 {
5933 return qe_invalid;
5934 }
5935 }
5936
5937 //save game icons
5938
3/4
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
89 if((Header->zelda_version < 0x192)||
5939
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 59 times.
65 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5940 {
5941 18 icons=3;
5942 18 }
5943
5944
2/2
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 83 times.
397 for(int32_t i=0; i<icons; i++)
5945 {
5946
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if(!p_igetw(&temp_misc.icons[i],f))
5947 {
5948 return qe_invalid;
5949 }
5950 314 }
5951 83 }
5952
5953
3/4
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
787 if((Header->zelda_version < 0x192)||
5954
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 757 times.
763 ((Header->zelda_version == 0x192)&&(Header->build<30)))
5955 {
5956 18 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5957
5958 18 return 0;
5959 }
5960
5961 //pond information
5962
2/2
✓ Branch 0 taken 757 times.
✓ Branch 1 taken 6 times.
763 if(Header->zelda_version < 0x193)
5963 {
5964
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<146))
5965 {
5966 pondsize=25;
5967 }
5968
5969
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 6 times.
102 for(int32_t i=0; i<ponds; i++)
5970 {
5971
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 96 times.
7008 for(int32_t j=0; j<pondsize; j++)
5972 {
5973
1/2
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
6912 if(!p_getc(&tempbyte,f))
5974 {
5975 return qe_invalid;
5976
5977 }
5978 6912 }
5979 96 }
5980 6 }
5981
5982 //end string
5983
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
769 if((Header->zelda_version < 0x192)||
5984
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 757 times.
763 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5985 {
5986 if(!p_getc(&tempbyte,f))
5987 {
5988 return qe_invalid;
5989 }
5990
5991 temp_misc.endstring=tempbyte;
5992
5993 if(!p_getc(&tempbyte,f))
5994 {
5995 return qe_invalid;
5996 }
5997 }
5998 else
5999 {
6000
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!p_igetw(&temp_misc.endstring,f))
6001 {
6002 return qe_invalid;
6003 }
6004 }
6005
6006 //expansion
6007
2/2
✓ Branch 0 taken 757 times.
✓ Branch 1 taken 6 times.
763 if(Header->zelda_version < 0x193)
6008 {
6009
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<73))
6010 {
6011 expansionsize=99*2;
6012 }
6013
6014
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 6 times.
1182 for(int32_t i=0; i<expansionsize; i++)
6015 {
6016
1/2
✓ Branch 0 taken 1176 times.
✗ Branch 1 not taken.
1176 if(!p_getc(&tempbyte,f))
6017 {
6018 return qe_invalid;
6019 }
6020 1176 }
6021 6 }
6022 //shops v8
6023
6024
6025
2/2
✓ Branch 0 taken 584 times.
✓ Branch 1 taken 179 times.
763 if(s_version >= 8)
6026 {
6027
2/2
✓ Branch 0 taken 2128 times.
✓ Branch 1 taken 179 times.
2307 for(int32_t i=0; i<shops; i++)
6028 {
6029
2/2
✓ Branch 0 taken 6384 times.
✓ Branch 1 taken 2128 times.
8512 for(int32_t j=0; j<3; j++)
6030 {
6031
1/2
✓ Branch 0 taken 6384 times.
✗ Branch 1 not taken.
6384 if(!p_igetw(&temp_misc.shop[i].str[j],f))
6032 return qe_invalid;
6033 6384 }
6034 2128 }
6035 179 }
6036
6037 763 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6038 763 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6039
6040 //v9 includes quest misc[32]
6041 // ... this has been deprecated (2024)
6042
2/2
✓ Branch 0 taken 584 times.
✓ Branch 1 taken 179 times.
763 if(s_version >= 9)
6043 {
6044
2/2
✓ Branch 0 taken 5728 times.
✓ Branch 1 taken 179 times.
5907 for ( int32_t q = 0; q < 32; q++ )
6045 {
6046
1/2
✓ Branch 0 taken 5728 times.
✗ Branch 1 not taken.
5728 if(!p_igetl(&temp_misc.questmisc[q],f))
6047 return qe_invalid;
6048 5728 }
6049 // this was string labels
6050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 179 times.
179 if (pack_fseek(f, 32 * 128))
6051 return qe_invalid;
6052 179 }
6053
6054
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 584 times.
763 if(s_version >= 11 )
6055 {
6056
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6057 return qe_invalid;
6058 179 }
6059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 584 times.
584 else if(s_version < 11 )
6060 {
6061 584 temp_misc.zscript_last_compiled_version = -1;
6062 584 }
6063
6064 763 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6065
6066
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 584 times.
763 if(s_version >= 12)
6067 {
6068 byte spr;
6069
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 179 times.
46003 for(int32_t q = 0; q < sprMAX; ++q)
6070 {
6071
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_getc(&spr,f))
6072 return qe_invalid;
6073 45824 temp_misc.sprites[q] = spr;
6074 45824 }
6075 179 }
6076 else
6077 {
6078 584 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6079 //temp_misc.sprites[sprFALL] = ;
6080 }
6081
6082
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 584 times.
763 if(s_version >= 13)
6083 {
6084
2/2
✓ Branch 0 taken 11456 times.
✓ Branch 1 taken 179 times.
11635 for(size_t q = 0; q < 64; ++q)
6085 {
6086 11456 bottletype* bt = &(temp_misc.bottle_types[q]);
6087
1/2
✓ Branch 0 taken 11456 times.
✗ Branch 1 not taken.
11456 if (!p_getstr(bt->name, sizeof(bt->name)-1, f))
6088 return qe_invalid;
6089
2/2
✓ Branch 0 taken 34368 times.
✓ Branch 1 taken 11456 times.
45824 for(size_t j = 0; j < 3; ++j)
6090 {
6091
1/2
✓ Branch 0 taken 34368 times.
✗ Branch 1 not taken.
34368 if (!p_getc(&(bt->counter[j]), f))
6092 return qe_invalid;
6093
1/2
✓ Branch 0 taken 34368 times.
✗ Branch 1 not taken.
34368 if (!p_igetw(&(bt->amount[j]), f))
6094 return qe_invalid;
6095 34368 }
6096
1/2
✓ Branch 0 taken 11456 times.
✗ Branch 1 not taken.
11456 if (!p_getc(&(bt->flags), f))
6097 return qe_invalid;
6098
1/2
✓ Branch 0 taken 11456 times.
✗ Branch 1 not taken.
11456 if (!p_getc(&(bt->next_type), f))
6099 return qe_invalid;
6100 11456 }
6101
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 179 times.
46003 for(size_t q = 0; q < 256; ++q)
6102 {
6103 45824 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6104
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if (!pfread(bst->name, sizeof(bst->name)-1, f))
6105 return qe_invalid;
6106
2/2
✓ Branch 0 taken 137472 times.
✓ Branch 1 taken 45824 times.
183296 for(size_t j = 0; j < 3; ++j)
6107 {
6108
1/2
✓ Branch 0 taken 137472 times.
✗ Branch 1 not taken.
137472 if (!p_getc(&(bst->fill[j]), f))
6109 return qe_invalid;
6110
1/2
✓ Branch 0 taken 137472 times.
✗ Branch 1 not taken.
137472 if (!p_igetw(&(bst->comb[j]), f))
6111 return qe_invalid;
6112
1/2
✓ Branch 0 taken 137472 times.
✗ Branch 1 not taken.
137472 if (!p_getc(&(bst->cset[j]), f))
6113 return qe_invalid;
6114
1/2
✓ Branch 0 taken 137472 times.
✗ Branch 1 not taken.
137472 if (!p_igetw(&(bst->price[j]), f))
6115 return qe_invalid;
6116
1/2
✓ Branch 0 taken 137472 times.
✗ Branch 1 not taken.
137472 if (!p_igetw(&(bst->str[j]), f))
6117 return qe_invalid;
6118 137472 }
6119 45824 }
6120 179 }
6121 else
6122 {
6123
2/2
✓ Branch 0 taken 37376 times.
✓ Branch 1 taken 584 times.
37960 for(size_t q = 0; q < 64; ++q)
6124 37376 temp_misc.bottle_types[q].clear();
6125
2/2
✓ Branch 0 taken 149504 times.
✓ Branch 1 taken 584 times.
150088 for(size_t q = 0; q < 256; ++q)
6126 149504 temp_misc.bottle_shop_types[q].clear();
6127 }
6128
6129
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 584 times.
763 if(s_version >= 14)
6130 {
6131 byte msfx;
6132
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 179 times.
46003 for(int32_t q = 0; q < sfxMAX; ++q)
6133 {
6134
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_getc(&msfx,f))
6135 return qe_invalid;
6136 45824 temp_misc.miscsfx[q] = msfx;
6137 45824 }
6138 179 }
6139 else
6140 {
6141 584 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6142 584 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6143 584 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6144 }
6145
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 584 times.
763 if(s_version < 15)
6146 {
6147 584 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6148 584 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6149 584 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6150 584 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6151 584 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6152 584 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6153 584 }
6154
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 601 times.
763 if(s_version < 16)
6155 {
6156 601 temp_misc.miscsfx[sfxTAP] = WAV_ZN1TAP;
6157 601 temp_misc.miscsfx[sfxTAP_HOLLOW] = WAV_ZN1TAP2;
6158 601 }
6159
6160
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 762 times.
763 if (!should_skip)
6161 762 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6162
6163 763 return 0;
6164 781 }
6165
6166 extern char *item_string[MAXITEMS];
6167 extern const char *old_item_string[iLast];
6168 extern char *weapon_string[MAXWPNS];
6169 extern const char *old_weapon_string[wLast];
6170
6171 467 int32_t readitems(PACKFILE *f, word version, word build)
6172 {
6173
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 24 times.
467 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_items);
6174
6175 byte padding;
6176 int32_t dummy;
6177 467 word items_to_read=MAXITEMS;
6178 itemdata tempitem;
6179 467 word s_version=0;
6180 word dummy_word;
6181
6182
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 6 times.
467 if(version < 0x186)
6183 {
6184 6 items_to_read=64;
6185 6 }
6186
6187
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 443 times.
467 if(version > 0x192)
6188 {
6189 443 items_to_read=0;
6190
6191 //section version info
6192
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetw(&s_version,f))
6193 {
6194 return qe_invalid;
6195 }
6196
6197 443 FFCore.quest_format[vItems] = s_version;
6198
6199
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!read_deprecated_section_cversion(f))
6200 {
6201 return qe_invalid;
6202 }
6203
6204 //section size
6205
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetl(&dummy,f))
6206 {
6207 return qe_invalid;
6208 }
6209
6210 //finally... section data
6211
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetw(&items_to_read,f))
6212 {
6213 return qe_invalid;
6214 }
6215
6216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if (items_to_read > MAXITEMS)
6217 {
6218 return qe_invalid;
6219 }
6220 443 }
6221
6222
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 83 times.
467 if(s_version>1)
6223 {
6224
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 384 times.
98688 for(int32_t i=0; i<items_to_read; i++)
6225 {
6226 char tempname[64];
6227
6228
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!pfread(tempname, 64, f))
6229 {
6230 return qe_invalid;
6231 }
6232
6233 98304 item_string[i][0] = '\0';
6234 98304 strncat(item_string[i], tempname, 64 - 1);
6235 98304 }
6236 384 }
6237
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
6238 {
6239
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
6240 {
6241 20992 reset_itemname(i);
6242 20992 }
6243 82 }
6244
6245
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 466 times.
467 if (!should_skip)
6246
2/2
✓ Branch 0 taken 119296 times.
✓ Branch 1 taken 466 times.
119762 for(int32_t i=0; i<MAXITEMS; i++)
6247 {
6248 119296 itemdata& id = itemsbuf[i];
6249 119296 memset(&id, 0, sizeof(itemdata));
6250 119296 id.count=-1;
6251 119296 id.playsound=WAV_SCALE;
6252 119296 reset_itembuf(&id,i);
6253 119762 }
6254
6255
2/2
✓ Branch 0 taken 107426 times.
✓ Branch 1 taken 467 times.
107893 for(int32_t i=0; i<items_to_read; i++)
6256 {
6257 107426 memset(&tempitem, 0, sizeof(itemdata));
6258 107426 reset_itembuf(&tempitem,i);
6259
6260
6261
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 61602 times.
107426 if ( s_version > 35 ) //expanded tiles
6262 {
6263
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_igetl(&tempitem.tile,f))
6264 {
6265 return qe_invalid;
6266 }
6267 45824 }
6268 else
6269 {
6270
1/2
✓ Branch 0 taken 61602 times.
✗ Branch 1 not taken.
61602 if(!p_igetw(&tempitem.tile,f))
6271 {
6272 return qe_invalid;
6273 }
6274 }
6275
6276
1/2
✓ Branch 0 taken 107426 times.
✗ Branch 1 not taken.
107426 if(!p_getc(&tempitem.misc_flags,f))
6277 {
6278 return qe_invalid;
6279 }
6280
6281
1/2
✓ Branch 0 taken 107426 times.
✗ Branch 1 not taken.
107426 if(!p_getc(&tempitem.csets,f))
6282 {
6283 return qe_invalid;
6284 }
6285
6286
1/2
✓ Branch 0 taken 107426 times.
✗ Branch 1 not taken.
107426 if(!p_getc(&tempitem.frames,f))
6287 {
6288 return qe_invalid;
6289 }
6290
6291
1/2
✓ Branch 0 taken 107426 times.
✗ Branch 1 not taken.
107426 if(!p_getc(&tempitem.speed,f))
6292 {
6293 return qe_invalid;
6294 }
6295
6296
1/2
✓ Branch 0 taken 107426 times.
✗ Branch 1 not taken.
107426 if(!p_getc(&tempitem.delay,f))
6297 {
6298 return qe_invalid;
6299 }
6300
6301
2/2
✓ Branch 0 taken 102434 times.
✓ Branch 1 taken 4992 times.
107426 if(version < 0x193)
6302 {
6303
1/2
✓ Branch 0 taken 4992 times.
✗ Branch 1 not taken.
4992 if(!p_getc(&padding,f))
6304 {
6305 return qe_invalid;
6306 }
6307
6308
4/6
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 3456 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✗ Branch 5 not taken.
4992 if((version < 0x192)||((version == 0x192)&&(build<186)))
6309 {
6310
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 4736 times.
4992 if (should_skip)
6311 256 continue;
6312
6313
3/3
✓ Branch 0 taken 4690 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
4736 switch(i)
6314 {
6315 case iShield:
6316 23 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6317 23 break;
6318
6319 case iMShield:
6320 23 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6321 23 break;
6322
6323 default:
6324 4690 tempitem.ltm=0;
6325 4690 break;
6326 }
6327
6328 4736 tempitem.count=-1;
6329 4736 tempitem.flags=item_none;
6330 4736 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6331 4736 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6332 4736 tempitem.family=0xFF;
6333 4736 tempitem.playsound=WAV_SCALE;
6334 4736 reset_itembuf(&tempitem,i);
6335
6336 4736 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6337
6338 4736 continue;
6339 }
6340 }
6341
6342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102434 times.
102434 if(!p_igetl(&tempitem.ltm,f))
6343 {
6344 return qe_invalid;
6345 }
6346
6347
1/2
✓ Branch 0 taken 102434 times.
✗ Branch 1 not taken.
102434 if(version < 0x193)
6348 {
6349 for(int32_t q=0; q<12; q++)
6350 {
6351 if(!p_getc(&padding,f))
6352 {
6353 return qe_invalid;
6354 }
6355 }
6356 }
6357
6358
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 4130 times.
102434 if(s_version>1)
6359 {
6360
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 52480 times.
98304 if ( s_version >= 31 )
6361 {
6362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45824 times.
45824 if(!p_igetl(&tempitem.family,f))
6363 {
6364 return qe_invalid;
6365 }
6366 45824 }
6367 else
6368 {
6369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52480 times.
52480 if(!p_getc(&tempitem.family,f))
6370 {
6371 return qe_invalid;
6372 }
6373 }
6374
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(s_version < 16)
6375 if(tempitem.family == 0xFF)
6376 tempitem.family = itype_misc;
6377
6378
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_getc(&tempitem.fam_type,f))
6379 {
6380 return qe_invalid;
6381 }
6382
6383
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(s_version>5)
6384 {
6385
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 52480 times.
98304 if(s_version>=31)
6386 {
6387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45824 times.
45824 if(!p_igetl(&tempitem.power,f))
6388 {
6389 return qe_invalid;
6390 }
6391 45824 }
6392 else
6393 {
6394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52480 times.
52480 if(!p_getc(&tempitem.power,f))
6395 {
6396 return qe_invalid;
6397 }
6398 }
6399
6400 //converted flags from 16b to 32b -Z
6401
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 45824 times.
98304 if ( s_version < 41 )
6402 {
6403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52480 times.
52480 if(!p_igetw(&tempitem.flags,f))
6404 {
6405 return qe_invalid;
6406 }
6407 52480 }
6408 else
6409 {
6410
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_igetl(&tempitem.flags,f))
6411 {
6412 return qe_invalid;
6413 }
6414 }
6415 98304 }
6416 else
6417 {
6418 //tempitem.power = tempitem.fam_type;
6419 char tempchar;
6420
6421 if(!p_getc(&tempchar,f))
6422 {
6423 return qe_invalid;
6424 }
6425
6426 if (tempchar) tempitem.flags |= item_gamedata;
6427 }
6428
6429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_igetw(&tempitem.script,f))
6430 {
6431 return qe_invalid;
6432 }
6433
6434
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(s_version<=3)
6435 {
6436 if(tempitem.script > NUMSCRIPTITEM)
6437 {
6438 tempitem.script = 0;
6439 }
6440 }
6441
6442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_getc(&tempitem.count,f))
6443 {
6444 return qe_invalid;
6445 }
6446
6447
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetw(&tempitem.amount,f))
6448 {
6449 return qe_invalid;
6450 }
6451
6452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_igetw(&tempitem.collect_script,f))
6453 {
6454 return qe_invalid;
6455 }
6456
6457
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(s_version<=3)
6458 {
6459 if(tempitem.collect_script > NUMSCRIPTITEM)
6460 {
6461 tempitem.collect_script = 0;
6462 }
6463 }
6464
6465
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetw(&tempitem.setmax,f))
6466 {
6467 return qe_invalid;
6468 }
6469
6470
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetw(&tempitem.max,f))
6471 {
6472 return qe_invalid;
6473 }
6474
6475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_getc(&tempitem.playsound,f))
6476 {
6477 return qe_invalid;
6478 }
6479
6480
2/2
✓ Branch 0 taken 786432 times.
✓ Branch 1 taken 98304 times.
884736 for(int32_t j=0; j<8; j++)
6481 {
6482
1/2
✓ Branch 0 taken 786432 times.
✗ Branch 1 not taken.
786432 if(!p_igetl(&tempitem.initiald[j],f))
6483 {
6484 return qe_invalid;
6485 }
6486 786432 }
6487
6488
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 98304 times.
294912 for(int32_t j=0; j<2; j++)
6489 {
6490 byte temp;
6491
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_getc(&temp,f))
6492 {
6493 return qe_invalid;
6494 }
6495 196608 }
6496
6497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(s_version>4)
6498 {
6499
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(s_version>5)
6500 {
6501
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_getc(&tempitem.wpn,f))
6502 {
6503 return qe_invalid;
6504 }
6505
6506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_getc(&tempitem.wpn2,f))
6507 {
6508 return qe_invalid;
6509 }
6510
6511
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_getc(&tempitem.wpn3,f))
6512 {
6513 return qe_invalid;
6514 }
6515
6516
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_getc(&tempitem.wpn4,f))
6517 {
6518 return qe_invalid;
6519 }
6520
6521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(s_version>=15)
6522 {
6523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_getc(&tempitem.wpn5,f))
6524 {
6525 return qe_invalid;
6526 }
6527
6528
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_getc(&tempitem.wpn6,f))
6529 {
6530 return qe_invalid;
6531 }
6532
6533
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_getc(&tempitem.wpn7,f))
6534 {
6535 return qe_invalid;
6536 }
6537
6538
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_getc(&tempitem.wpn8,f))
6539 {
6540 return qe_invalid;
6541 }
6542
6543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_getc(&tempitem.wpn9,f))
6544 {
6545 return qe_invalid;
6546 }
6547
6548
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_getc(&tempitem.wpn10,f))
6549 {
6550 return qe_invalid;
6551 }
6552 98304 }
6553
6554
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_getc(&tempitem.pickup_hearts,f))
6555 {
6556 return qe_invalid;
6557 }
6558
6559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(s_version<15)
6560 {
6561 if(!p_igetw(&dummy_word,f))
6562 {
6563 return qe_invalid;
6564 }
6565
6566 tempitem.misc1=dummy_word;
6567
6568 if(!p_igetw(&dummy_word,f))
6569 {
6570 return qe_invalid;
6571 }
6572
6573 tempitem.misc2=dummy_word;
6574 }
6575 else
6576 {
6577
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&tempitem.misc1,f))
6578 {
6579 return qe_invalid;
6580 }
6581
6582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_igetl(&tempitem.misc2,f))
6583 {
6584 return qe_invalid;
6585 }
6586
6587 // Version 24: sh_ice -> sh_script; previously, all shields could block script weapons
6588
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(s_version<24)
6589 {
6590 if(tempitem.family==itype_shield)
6591 {
6592 tempitem.misc1|=sh_script;
6593 }
6594 }
6595 }
6596
6597
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 45824 times.
98304 if(s_version < 53)
6598 {
6599 byte tempbyte;
6600
1/2
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
52480 if(!p_getc(&tempbyte,f))
6601 {
6602 return qe_invalid;
6603 }
6604 52480 tempitem.cost_amount[0] = tempbyte;
6605 52480 }
6606 else
6607 {
6608
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 45824 times.
137472 for(auto q = 0; q < 2; ++q)
6609 {
6610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91648 times.
91648 if(!p_igetw(&tempitem.cost_amount[q],f))
6611 {
6612 return qe_invalid;
6613 }
6614 91648 }
6615 }
6616 98304 }
6617 else
6618 {
6619 char tempchar;
6620
6621 if(!p_getc(&tempchar,f))
6622 {
6623 return qe_invalid;
6624 }
6625
6626 if (tempchar) tempitem.flags |= item_edible;
6627 }
6628
6629 // June 2007: more misc. attributes
6630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(s_version>=12)
6631 {
6632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(s_version<15)
6633 {
6634 if(!p_igetw(&dummy_word,f))
6635 {
6636 return qe_invalid;
6637 }
6638
6639 tempitem.misc3=dummy_word;
6640
6641 if(!p_igetw(&dummy_word,f))
6642 {
6643 return qe_invalid;
6644 }
6645
6646 tempitem.misc4=dummy_word;
6647 }
6648 else
6649 {
6650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_igetl(&tempitem.misc3,f))
6651 {
6652 return qe_invalid;
6653 }
6654
6655
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&tempitem.misc4,f))
6656 {
6657 return qe_invalid;
6658 }
6659
6660
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&tempitem.misc5,f))
6661 {
6662 return qe_invalid;
6663 }
6664
6665
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&tempitem.misc6,f))
6666 {
6667 return qe_invalid;
6668 }
6669
6670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_igetl(&tempitem.misc7,f))
6671 {
6672 return qe_invalid;
6673 }
6674
6675
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&tempitem.misc8,f))
6676 {
6677 return qe_invalid;
6678 }
6679
6680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_igetl(&tempitem.misc9,f))
6681 {
6682 return qe_invalid;
6683 }
6684
6685
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&tempitem.misc10,f))
6686 {
6687 return qe_invalid;
6688 }
6689 }
6690
6691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_getc(&tempitem.usesound,f))
6692 {
6693 return qe_invalid;
6694 }
6695
6696
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 52480 times.
98304 if(s_version >= 49)
6697 {
6698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45824 times.
45824 if(!p_getc(&tempitem.usesound2,f))
6699 {
6700 return qe_invalid;
6701 }
6702 45824 }
6703 52480 else tempitem.usesound2 = 0;
6704
6705
3/4
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 45824 times.
✓ Branch 2 taken 52480 times.
✗ Branch 3 not taken.
98304 if(s_version < 50 && tempitem.family == itype_mirror)
6706 {
6707 //Split continue/dmap warp effect/sfx, port for old
6708 tempitem.misc2 = tempitem.misc1;
6709 tempitem.usesound2 = tempitem.usesound;
6710 }
6711 98304 }
6712 98304 }
6713
6714
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 45824 times.
98304 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6715 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45824 times.
45824 if(!p_getc(&tempitem.useweapon,f))
6717 {
6718 return qe_invalid;
6719 }
6720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45824 times.
45824 if(!p_getc(&tempitem.usedefence,f))
6721 {
6722 return qe_invalid;
6723 }
6724
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_igetl(&tempitem.weaprange,f))
6725 {
6726 return qe_invalid;
6727 }
6728
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_igetl(&tempitem.weapduration,f))
6729 {
6730 return qe_invalid;
6731 }
6732
2/2
✓ Branch 0 taken 458240 times.
✓ Branch 1 taken 45824 times.
504064 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6733 {
6734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 458240 times.
458240 if(!p_igetl(&tempitem.weap_pattern[q],f))
6735 {
6736 return qe_invalid;
6737 }
6738 458240 }
6739 45824 }
6740
6741
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 45824 times.
98304 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6742 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6743
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_igetl(&tempitem.duplicates,f))
6744 {
6745 return qe_invalid;
6746 }
6747
2/2
✓ Branch 0 taken 366592 times.
✓ Branch 1 taken 45824 times.
412416 for ( int32_t q = 0; q < INITIAL_D; q++ )
6748 {
6749
1/2
✓ Branch 0 taken 366592 times.
✗ Branch 1 not taken.
366592 if(!p_igetl(&tempitem.weap_initiald[q],f))
6750 {
6751 return qe_invalid;
6752 }
6753 366592 }
6754
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 45824 times.
137472 for ( int32_t q = 0; q < 2; q++ )
6755 {
6756 byte temp;
6757
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_getc(&temp,f))
6758 {
6759 return qe_invalid;
6760 }
6761 91648 }
6762
6763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45824 times.
45824 if(!p_getc(&tempitem.drawlayer,f))
6764 {
6765 return qe_invalid;
6766 }
6767
6768
6769
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_igetl(&tempitem.hxofs,f))
6770 {
6771 return qe_invalid;
6772 }
6773
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_igetl(&tempitem.hyofs,f))
6774 {
6775 return qe_invalid;
6776 }
6777
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_igetl(&tempitem.hxsz,f))
6778 {
6779 return qe_invalid;
6780 }
6781
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_igetl(&tempitem.hysz,f))
6782 {
6783 return qe_invalid;
6784 }
6785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45824 times.
45824 if(!p_igetl(&tempitem.hzsz,f))
6786 {
6787 return qe_invalid;
6788 }
6789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45824 times.
45824 if(!p_igetl(&tempitem.xofs,f))
6790 {
6791 return qe_invalid;
6792 }
6793
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_igetl(&tempitem.yofs,f))
6794 {
6795 return qe_invalid;
6796 }
6797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45824 times.
45824 if(!p_igetl(&tempitem.weap_hxofs,f))
6798 {
6799 return qe_invalid;
6800 }
6801
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_igetl(&tempitem.weap_hyofs,f))
6802 {
6803 return qe_invalid;
6804 }
6805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45824 times.
45824 if(!p_igetl(&tempitem.weap_hxsz,f))
6806 {
6807 return qe_invalid;
6808 }
6809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45824 times.
45824 if(!p_igetl(&tempitem.weap_hysz,f))
6810 {
6811 return qe_invalid;
6812 }
6813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45824 times.
45824 if(!p_igetl(&tempitem.weap_hzsz,f))
6814 {
6815 return qe_invalid;
6816 }
6817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45824 times.
45824 if(!p_igetl(&tempitem.weap_xofs,f))
6818 {
6819 return qe_invalid;
6820 }
6821
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_igetl(&tempitem.weap_yofs,f))
6822 {
6823 return qe_invalid;
6824 }
6825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45824 times.
45824 if(!p_igetw(&tempitem.weaponscript,f))
6826 {
6827 return qe_invalid;
6828 }
6829
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_igetl(&tempitem.wpnsprite,f))
6830 {
6831 return qe_invalid;
6832 }
6833 45824 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6834
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 45824 times.
137472 for(auto q = 0; q < num_cost_tmr; ++q)
6835 {
6836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91648 times.
91648 if(!p_igetl(&tempitem.magiccosttimer[q],f))
6837 {
6838 return qe_invalid;
6839 }
6840 91648 }
6841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45824 times.
45824 for(auto q = num_cost_tmr; q < 2; ++q)
6842 tempitem.magiccosttimer[q] = 0;
6843 45824 }
6844
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 45824 times.
98304 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6845 {
6846 //Item Size FLags, TileWidth, TileHeight
6847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45824 times.
45824 if(!p_igetl(&tempitem.overrideFLAGS,f))
6848 {
6849 return qe_invalid;
6850 }
6851
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_igetl(&tempitem.tilew,f))
6852 {
6853 return qe_invalid;
6854 }
6855
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_igetl(&tempitem.tileh,f))
6856 {
6857 return qe_invalid;
6858 }
6859 45824 }
6860
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 45824 times.
98304 if ( s_version >= 29 ) //! More new vars.
6861 {
6862 //Item Size FLags, TileWidth, TileHeight
6863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45824 times.
45824 if(!p_igetl(&tempitem.weapoverrideFLAGS,f))
6864 {
6865 return qe_invalid;
6866 }
6867
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_igetl(&tempitem.weap_tilew,f))
6868 {
6869 return qe_invalid;
6870 }
6871
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_igetl(&tempitem.weap_tileh,f))
6872 {
6873 return qe_invalid;
6874 }
6875 45824 }
6876
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 45824 times.
98304 if ( s_version >= 30 ) //! More new vars.
6877 {
6878 //Pickup Type
6879
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_igetl(&tempitem.pickup,f))
6880 {
6881 return qe_invalid;
6882 }
6883 45824 }
6884
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 45824 times.
98304 if ( s_version >= 32 ) //! More new vars.
6885 {
6886 //Pickup Type
6887
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_igetw(&tempitem.pstring,f))
6888 {
6889 return qe_invalid;
6890 }
6891 45824 }
6892
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 45824 times.
98304 if ( s_version >= 33 ) //! More new vars.
6893 {
6894 //Pickup Type
6895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45824 times.
45824 if(!p_igetw(&tempitem.pickup_string_flags,f))
6896 {
6897 return qe_invalid;
6898 }
6899 45824 }
6900
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 45824 times.
98304 if ( s_version >= 34 ) //! cost counter
6901 {
6902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45824 times.
45824 if(s_version < 53)
6903 {
6904 if(!p_getc(&tempitem.cost_counter[0],f))
6905 {
6906 return qe_invalid;
6907 }
6908 }
6909 else
6910 {
6911
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 45824 times.
137472 for(auto q = 0; q < 2; ++q)
6912 {
6913
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_getc(&tempitem.cost_counter[q],f))
6914 {
6915 return qe_invalid;
6916 }
6917 91648 }
6918 }
6919 45824 }
6920
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 45824 times.
98304 if ( s_version >= 44 ) //! sprite scripts
6921 {
6922
2/2
✓ Branch 0 taken 366592 times.
✓ Branch 1 taken 45824 times.
412416 for ( int32_t q = 0; q < 8; q++ )
6923 {
6924
2/2
✓ Branch 0 taken 23828480 times.
✓ Branch 1 taken 366592 times.
24195072 for ( int32_t w = 0; w < 65; w++ )
6925 {
6926
1/2
✓ Branch 0 taken 23828480 times.
✗ Branch 1 not taken.
23828480 if(!p_getc(&(tempitem.initD_label[q][w]),f))
6927 {
6928 return qe_invalid;
6929 }
6930 23828480 }
6931
2/2
✓ Branch 0 taken 23828480 times.
✓ Branch 1 taken 366592 times.
24195072 for ( int32_t w = 0; w < 65; w++ )
6932 {
6933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23828480 times.
23828480 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f))
6934 {
6935 return qe_invalid;
6936 }
6937 23828480 }
6938
2/2
✓ Branch 0 taken 23828480 times.
✓ Branch 1 taken 366592 times.
24195072 for ( int32_t w = 0; w < 65; w++ )
6939 {
6940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23828480 times.
23828480 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
6941 {
6942 return qe_invalid;
6943 }
6944 23828480 }
6945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 366592 times.
366592 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
6946 {
6947 return qe_invalid;
6948 }
6949
6950 366592 }
6951
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 45824 times.
137472 for ( int32_t q = 0; q < 2; q++ )
6952 {
6953 byte temp;
6954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91648 times.
91648 if(!p_getc(&temp,f))
6955 {
6956 return qe_invalid;
6957 }
6958 91648 }
6959 //Pickup Type
6960
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_igetw(&tempitem.sprite_script,f))
6961 {
6962 return qe_invalid;
6963 }
6964 45824 }
6965
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 45824 times.
98304 if ( s_version >= 48 ) //! pickup flags
6966 {
6967
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_getc(&(tempitem.pickupflag),f))
6968 {
6969 return qe_invalid;
6970 }
6971 45824 }
6972
2/2
✓ Branch 0 taken 55808 times.
✓ Branch 1 taken 42496 times.
98304 if ( s_version >= 57 )
6973 {
6974 42496 std::string str;
6975
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42496 times.
✓ Branch 2 taken 42496 times.
✗ Branch 3 not taken.
42496 if(!p_getcstr(&str,f))
6976 return qe_invalid;
6977 42496 strncpy(tempitem.display_name,str.c_str(),255);
6978
1/3
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
42496 }
6979 98304 }
6980 else
6981 {
6982 4130 tempitem.count=-1;
6983 4130 tempitem.family=itype_misc;
6984 4130 tempitem.flags=item_none;
6985 4130 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6986 4130 tempitem.playsound=WAV_SCALE;
6987 4130 reset_itembuf(&tempitem,i);
6988 }
6989
6990
2/2
✓ Branch 0 taken 60962 times.
✓ Branch 1 taken 41472 times.
102434 if(s_version >= 58)
6991 {
6992
2/2
✓ Branch 0 taken 207360 times.
✓ Branch 1 taken 41472 times.
248832 for(int q = 0; q < WPNSPR_MAX; ++q)
6993 {
6994
1/2
✓ Branch 0 taken 207360 times.
✗ Branch 1 not taken.
207360 if(!p_getc(&tempitem.burnsprs[q],f))
6995 return qe_invalid;
6996
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 206080 times.
207360 if(s_version >= 59)
6997
1/2
✓ Branch 0 taken 206080 times.
✗ Branch 1 not taken.
206080 if(!p_getc(&tempitem.light_rads[q],f))
6998 return qe_invalid;
6999 207360 }
7000 41472 }
7001
7002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102434 times.
102434 if (!should_skip)
7003 {
7004
1/2
✓ Branch 0 taken 102434 times.
✗ Branch 1 not taken.
102434 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
7005 {
7006 tempitem.script = 0;
7007 tempitem.weaponscript = 0;
7008 for(int q = 0; q < 8; ++q)
7009 {
7010 tempitem.initiald[q] = 0;
7011 tempitem.weap_initiald[q] = 0;
7012 }
7013 }
7014 102434 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7015 102434 }
7016 102434 }
7017
7018
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 466 times.
467 if (should_skip)
7019 1 return 0;
7020
7021 //////////////////////////////////////////////////////
7022 // Now do any updates because of new item additions
7023 // (These can't be done above because items_to_read
7024 // might be too low.)
7025 //////////////////////////////////////////////////////
7026
2/2
✓ Branch 0 taken 119296 times.
✓ Branch 1 taken 466 times.
119762 for(int32_t i=0; i<MAXITEMS; i++)
7027 {
7028 119296 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7029
7030 //Account for older quests that didn't have an actual item for the used letter
7031
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 98304 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
119296 if(s_version < 2 && i==iLetterUsed)
7032 {
7033 82 reset_itembuf(&tempitem, iLetterUsed);
7034 82 strcpy(item_string[i],old_item_string[i]);
7035 82 tempitem.tile = itemsbuf[iLetter].tile;
7036 82 tempitem.csets = itemsbuf[iLetter].csets;
7037 82 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7038 82 tempitem.frames = itemsbuf[iLetter].frames;
7039 82 tempitem.speed = itemsbuf[iLetter].speed;
7040 82 tempitem.ltm = itemsbuf[iLetter].ltm;
7041 82 }
7042
7043
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 3)
7044 {
7045
3/3
✓ Branch 0 taken 1804 times.
✓ Branch 1 taken 19106 times.
✓ Branch 2 taken 82 times.
20992 switch(i)
7046 {
7047 case iRocsFeather:
7048 case iHoverBoots:
7049 case iSpinScroll:
7050 case iL2SpinScroll:
7051 case iCrossScroll:
7052 case iQuakeScroll:
7053 case iL2QuakeScroll:
7054 case iWhispRing:
7055 case iL2WhispRing:
7056 case iChargeRing:
7057 case iL2ChargeRing:
7058 case iPerilScroll:
7059 case iWalletL3:
7060 case iQuiverL4:
7061 case iBombBagL4:
7062 case iBracelet:
7063 case iL2Bracelet:
7064 case iOldGlove:
7065 case iL2Ladder:
7066 case iWealthMedal:
7067 case iL2WealthMedal:
7068 case iL3WealthMedal:
7069 1804 reset_itembuf(&tempitem, i);
7070 1804 strcpy(item_string[i],old_item_string[i]);
7071 1804 break;
7072
7073 case iSShield:
7074 82 reset_itembuf(&tempitem, i);
7075 82 strcpy(item_string[i],old_item_string[i]);
7076 82 strcpy(item_string[iShield],old_item_string[iShield]);
7077 82 strcpy(item_string[iMShield],old_item_string[iMShield]);
7078 82 break;
7079 }
7080 20992 }
7081
7082
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 5)
7083 {
7084
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 20418 times.
20992 switch(i)
7085 {
7086 case iHeartRing:
7087 case iL2HeartRing:
7088 case iL3HeartRing:
7089 case iMagicRing:
7090 case iL2MagicRing:
7091 case iL3MagicRing:
7092 case iL4MagicRing:
7093 574 reset_itembuf(&tempitem, i);
7094 574 strcpy(item_string[i],old_item_string[i]);
7095 574 break;
7096 }
7097 20992 }
7098
7099
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7100 {
7101
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(i!=iBPotion && i!=iRPotion)
7102
2/2
✓ Branch 0 taken 19304 times.
✓ Branch 1 taken 1524 times.
20828 if (get_bit(deprecated_rules,32)) tempitem.flags |= item_keep_old;
7103
7104
43/43
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 328 times.
✓ Branch 8 taken 17302 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
✓ Branch 11 taken 82 times.
✓ Branch 12 taken 82 times.
✓ Branch 13 taken 82 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
✓ Branch 16 taken 82 times.
✓ Branch 17 taken 82 times.
✓ Branch 18 taken 82 times.
✓ Branch 19 taken 82 times.
✓ Branch 20 taken 82 times.
✓ Branch 21 taken 82 times.
✓ Branch 22 taken 82 times.
✓ Branch 23 taken 82 times.
✓ Branch 24 taken 82 times.
✓ Branch 25 taken 82 times.
✓ Branch 26 taken 82 times.
✓ Branch 27 taken 82 times.
✓ Branch 28 taken 82 times.
✓ Branch 29 taken 82 times.
✓ Branch 30 taken 82 times.
✓ Branch 31 taken 82 times.
✓ Branch 32 taken 82 times.
✓ Branch 33 taken 82 times.
✓ Branch 34 taken 82 times.
✓ Branch 35 taken 82 times.
✓ Branch 36 taken 82 times.
✓ Branch 37 taken 82 times.
✓ Branch 38 taken 82 times.
✓ Branch 39 taken 82 times.
✓ Branch 40 taken 82 times.
✓ Branch 41 taken 82 times.
✓ Branch 42 taken 82 times.
20992 switch(i)
7105 {
7106 case iTriforce:
7107 82 tempitem.fam_type=1;
7108 82 break;
7109
7110 case iBigTri:
7111 82 tempitem.fam_type=0;
7112 82 break;
7113
7114 case iBombs:
7115 82 tempitem.fam_type=i_bomb;
7116 82 tempitem.power=4;
7117 82 tempitem.wpn=wBOMB;
7118 82 tempitem.wpn2=wBOOM;
7119 82 tempitem.misc1 = 50;
7120
7121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7122
7123 82 break;
7124
7125 case iSBomb:
7126 82 tempitem.fam_type=i_sbomb;
7127 82 tempitem.power=16;
7128 82 tempitem.wpn=wSBOMB;
7129 82 tempitem.wpn2=wSBOOM;
7130 82 tempitem.misc1 = 50;
7131
7132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7133
7134 82 break;
7135
7136 case iBook:
7137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7138 tempitem.wpn = wFIREMAGIC;
7139
7140 82 break;
7141
7142 case iSArrow:
7143 82 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7144 82 tempitem.power=4;
7145 82 tempitem.flags|=item_gamedata;
7146 82 tempitem.wpn=wSARROW;
7147 82 break;
7148
7149 case iGArrow:
7150 82 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7151 82 tempitem.power=8;
7152 82 tempitem.flags|=(item_gamedata|item_flag1);
7153 82 tempitem.wpn=wGARROW;
7154 82 break;
7155
7156 case iBrang:
7157 82 tempitem.power=0;
7158 82 tempitem.wpn=wBRANG;
7159 82 tempitem.misc1=36;
7160 82 break;
7161
7162 case iMBrang:
7163 82 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7164 82 tempitem.power=0;
7165 82 tempitem.wpn=wMBRANG;
7166 82 break;
7167
7168 case iFBrang:
7169 82 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7170 82 tempitem.power=2;
7171 82 tempitem.wpn=wFBRANG;
7172 82 break;
7173
7174 case iBoots:
7175 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7176 82 tempitem.power=7;
7177 82 break;
7178
7179 case iWand:
7180 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7181 82 tempitem.power=2;
7182 82 tempitem.wpn=wWAND;
7183 82 tempitem.wpn3=wMAGIC;
7184 82 break;
7185
7186 case iBCandle:
7187 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7188 82 tempitem.power=1;
7189 82 tempitem.flags|=(item_gamedata|item_flag1);
7190 82 tempitem.wpn3=wFIRE;
7191 82 break;
7192
7193 case iRCandle:
7194 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7195 82 tempitem.power=1;
7196 82 tempitem.wpn3=wFIRE;
7197 82 break;
7198
7199 case iSword:
7200 82 tempitem.power=1;
7201 82 tempitem.flags|= item_flag4 |item_flag2;
7202 82 tempitem.wpn=tempitem.wpn3=wSWORD;
7203 82 tempitem.wpn2=wSWORDSLASH;
7204 82 break;
7205
7206 case iWSword:
7207 82 tempitem.power=2;
7208 82 tempitem.flags|= item_flag4 |item_flag2;
7209 82 tempitem.wpn=tempitem.wpn3=wWSWORD;
7210 82 tempitem.wpn2=wWSWORDSLASH;
7211 82 break;
7212
7213 case iMSword:
7214 82 tempitem.power=4;
7215 82 tempitem.flags|= item_flag4 |item_flag2;
7216 82 tempitem.wpn=tempitem.wpn3=wMSWORD;
7217 82 tempitem.wpn2=wMSWORDSLASH;
7218 82 break;
7219
7220 case iXSword:
7221 82 tempitem.power=8;
7222 82 tempitem.flags|= item_flag4 |item_flag2;
7223 82 tempitem.wpn=tempitem.wpn3=wXSWORD;
7224 82 tempitem.wpn2=wXSWORDSLASH;
7225 82 break;
7226
7227 case iDivineProtection:
7228 82 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? item_flag1 : item_none;
7229 82 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? item_flag2 : item_none;
7230 82 tempitem.wpn=wDIVINEPROTECTION1A;
7231 82 tempitem.wpn2=wDIVINEPROTECTION1B;
7232 82 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7233 82 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7234 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7235 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7236 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7237 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7238 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7239 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7240 82 tempitem.misc1=512;
7241 82 tempitem.cost_amount[0]=64;
7242 82 break;
7243
7244 case iLens:
7245 82 tempitem.misc1=60;
7246 82 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? item_none : item_rupee_magic;
7247 82 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7248 82 break;
7249
7250 case iArrow:
7251 82 tempitem.power=2;
7252 82 tempitem.wpn=wARROW;
7253 82 break;
7254
7255 case iHoverBoots:
7256 82 tempitem.misc1=45;
7257 82 tempitem.wpn=iwHover;
7258 82 break;
7259
7260 case iDivineFire:
7261 82 tempitem.power=8;
7262 82 tempitem.wpn=wDIVINEFIRE1A;
7263 82 tempitem.wpn2=wDIVINEFIRE1B;
7264 82 tempitem.wpn3=wDIVINEFIRES1A;
7265 82 tempitem.wpn4=wDIVINEFIRES1B;
7266 82 tempitem.misc1 = 32;
7267 82 tempitem.misc2 = 200;
7268 82 tempitem.cost_amount[0]=32;
7269 82 break;
7270
7271 case iDivineEscape:
7272 82 tempitem.cost_amount[0]=32;
7273 82 break;
7274
7275 case iHookshot:
7276 82 tempitem.power=0;
7277 82 tempitem.flags&=~item_flag1;
7278 82 tempitem.wpn=wHSHEAD;
7279 82 tempitem.wpn2=wHSCHAIN_H;
7280 82 tempitem.wpn4=wHSHANDLE;
7281 82 tempitem.wpn3=wHSCHAIN_V;
7282 82 tempitem.misc1=50;
7283 82 tempitem.misc2=100;
7284 82 break;
7285
7286 case iLongshot:
7287 82 tempitem.power=0;
7288 82 tempitem.flags&=~item_flag1;
7289 82 tempitem.wpn=wLSHEAD;
7290 82 tempitem.wpn2=wLSCHAIN_H;
7291 82 tempitem.wpn4=wLSHANDLE;
7292 82 tempitem.wpn3=wLSCHAIN_V;
7293 82 tempitem.misc1=99;
7294 82 tempitem.misc2=100;
7295 82 break;
7296
7297 case iHammer:
7298 82 tempitem.power=4;
7299 82 tempitem.wpn=wHAMMER;
7300 82 tempitem.wpn2=iwHammerSmack;
7301 82 break;
7302
7303 case iCByrna:
7304 82 tempitem.power=1;
7305 82 tempitem.wpn=wCBYRNA;
7306 82 tempitem.wpn2=wCBYRNASLASH;
7307 82 tempitem.wpn3=wCBYRNAORB;
7308 82 tempitem.misc1=4;
7309 82 tempitem.misc2=16;
7310 82 tempitem.misc3=1;
7311 82 tempitem.cost_amount[0]=1;
7312 82 break;
7313
7314 case iWhistle:
7315 82 tempitem.wpn=wWIND;
7316 82 tempitem.misc1=3;
7317 82 tempitem.flags|=item_flag1;
7318 82 break;
7319
7320 case iBRing:
7321 82 tempitem.power=2;
7322 82 tempitem.misc1=spBLUE;
7323 82 break;
7324
7325 case iRRing:
7326 82 tempitem.power=4;
7327 82 tempitem.misc1=spRED;
7328 82 break;
7329
7330 case iGRing:
7331 82 tempitem.power=8;
7332 82 tempitem.misc1=spGOLD;
7333 82 break;
7334
7335 case iSpinScroll:
7336 82 tempitem.power = 2;
7337 82 tempitem.misc1 = 1;
7338 82 break;
7339
7340 case iL2SpinScroll:
7341 82 tempitem.family=itype_spinscroll2;
7342 82 tempitem.fam_type=1;
7343 82 tempitem.cost_amount[0]=8;
7344 82 tempitem.power=2;
7345 82 tempitem.misc1 = 20;
7346 82 break;
7347
7348 case iQuakeScroll:
7349 82 tempitem.misc1=0x10;
7350 82 tempitem.misc2=64;
7351 82 break;
7352
7353 case iL2QuakeScroll:
7354 82 tempitem.family=itype_quakescroll2;
7355 82 tempitem.fam_type=1;
7356 82 tempitem.power = 2;
7357 82 tempitem.misc1=0x20;
7358 82 tempitem.misc2=192;
7359 82 tempitem.cost_amount[0]=8;
7360 82 break;
7361
7362 case iChargeRing:
7363 82 tempitem.misc1=64;
7364 82 tempitem.misc2=128;
7365 82 break;
7366
7367 case iL2ChargeRing:
7368 82 tempitem.misc1=32;
7369 82 tempitem.misc2=64;
7370 82 break;
7371
7372 case iOldGlove:
7373 82 tempitem.flags |= item_flag1;
7374
7375 //fallthrough
7376 case iBombBagL4:
7377 case iWalletL3:
7378 case iQuiverL4:
7379 case iBracelet:
7380 410 tempitem.power = 1;
7381 410 break;
7382
7383 case iL2Bracelet:
7384 82 tempitem.power = 2;
7385 82 break;
7386
7387 case iMKey:
7388 82 tempitem.power=0xFF;
7389 82 tempitem.flags |= item_flag1;
7390 82 break;
7391 }
7392 20992 }
7393
7394
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 7)
7395 {
7396
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 20664 times.
20992 switch(i)
7397 {
7398 case iStoneAgony:
7399 case iStompBoots:
7400 case iPerilRing:
7401 case iWhimsicalRing:
7402 {
7403 328 reset_itembuf(&tempitem, i);
7404 328 strcpy(item_string[i],old_item_string[i]);
7405 328 break;
7406 }
7407 }
7408 20992 }
7409
7410
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 8) // May 2007: Some corrections.
7411 {
7412
7/7
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 20336 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
20992 switch(i)
7413 {
7414 case iMShield:
7415 82 tempitem.misc1|=sh_flame;
7416 82 tempitem.misc2|=sh_fireball|sh_magic;
7417
7418
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(get_qr(qr_SWORDMIRROR))
7419 {
7420 tempitem.misc2 |= sh_sword;
7421 }
7422
7423 // fallthrough
7424 case iShield:
7425 164 tempitem.misc1|=sh_fireball|sh_sword|sh_magic;
7426
7427 // fallthrough
7428 case iSShield:
7429 246 tempitem.misc1|=sh_rock|sh_arrow|sh_brang|sh_script;
7430
7431
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7432 {
7433 tempitem.misc2 |= sh_rock;
7434 }
7435
7436 246 break;
7437
7438 case iWhispRing:
7439 82 tempitem.power=1;
7440 82 tempitem.flags|=item_gamedata|item_flag1;
7441 82 tempitem.misc1 = 3;
7442 82 break;
7443
7444 case iL2WhispRing:
7445 82 tempitem.power=0;
7446 82 tempitem.flags|=item_gamedata|item_flag1;
7447 82 tempitem.misc1 = 3;
7448 82 break;
7449
7450 case iL2Ladder:
7451 case iBow:
7452 case iCByrna:
7453 246 tempitem.power = 1;
7454 246 break;
7455 }
7456 20992 }
7457
7458
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 98304 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
119296 if(s_version < 9 && i==iClock)
7459 {
7460 82 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7461 82 }
7462
7463 //add the misc flag for bomb
7464
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 98304 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
119296 if(s_version < 10 && tempitem.family == itype_bomb)
7465 {
7466 82 tempitem.flags = (tempitem.flags & ~item_flag1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? item_flag1 : item_none);
7467 82 }
7468
7469
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 98304 times.
✓ Branch 2 taken 20828 times.
✓ Branch 3 taken 164 times.
119296 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7470 {
7471 164 tempitem.flags = (tempitem.fam_type ? item_gamedata : item_none);
7472 164 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7473 164 }
7474
7475
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 12) // June 2007: More Misc. attributes.
7476 {
7477
5/5
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20582 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
20992 switch(i)
7478 {
7479 case iFBrang:
7480 82 tempitem.misc4 |= sh_fireball|sh_sword|sh_magic;
7481
7482 //fallthrough
7483 case iMBrang:
7484 164 tempitem.misc3 |= sh_sword|sh_magic;
7485
7486 //fallthrough
7487 case iHookshot:
7488 case iLongshot:
7489 //fallthrough
7490 328 tempitem.misc3 |= sh_fireball;
7491
7492 case iBrang:
7493 410 tempitem.misc3 |= sh_brang|sh_rock|sh_arrow;
7494 410 break;
7495 }
7496
7497
16/16
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 246 times.
✓ Branch 4 taken 246 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 328 times.
✓ Branch 9 taken 164 times.
✓ Branch 10 taken 9629 times.
✓ Branch 11 taken 164 times.
✓ Branch 12 taken 246 times.
✓ Branch 13 taken 9313 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
20992 switch(tempitem.family)
7498 {
7499 case itype_hoverboots:
7500 82 tempitem.usesound = WAV_ZN1HOVER;
7501 82 break;
7502
7503 case itype_wand:
7504 82 tempitem.usesound = WAV_WAND;
7505 82 break;
7506
7507 case itype_book:
7508 82 tempitem.usesound = WAV_FIRE;
7509 82 break;
7510
7511 case itype_arrow:
7512 246 tempitem.usesound = WAV_ARROW;
7513 246 break;
7514
7515 case itype_hookshot:
7516 164 tempitem.usesound = WAV_HOOKSHOT;
7517 164 break;
7518
7519 case itype_brang:
7520 246 tempitem.usesound = WAV_BRANG;
7521 246 break;
7522
7523 case itype_shield:
7524 246 tempitem.usesound = WAV_CHINK;
7525 246 break;
7526
7527 case itype_sword:
7528 9313 tempitem.usesound = WAV_SWORD;
7529 9313 break;
7530
7531 case itype_whistle:
7532 82 tempitem.usesound = WAV_WHISTLE;
7533 82 break;
7534
7535 case itype_hammer:
7536 82 tempitem.usesound = WAV_HAMMER;
7537 82 break;
7538
7539 case itype_divinefire:
7540 82 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7541 82 break;
7542
7543 case itype_divineescape:
7544 82 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7545 82 break;
7546
7547 case itype_divineprotection:
7548 82 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7549 82 break;
7550
7551 case itype_bomb:
7552 case itype_sbomb:
7553 case itype_quakescroll:
7554 case itype_quakescroll2:
7555 328 tempitem.usesound = WAV_BOMB;
7556 328 break;
7557
7558 case itype_spinscroll:
7559 case itype_spinscroll2:
7560 164 tempitem.usesound = WAV_ZN1SPINATTACK;
7561 164 break;
7562 }
7563 20992 }
7564
7565
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 13) // July 2007
7566 {
7567
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_whistle)
7568 {
7569 82 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7570 82 tempitem.power = 1;
7571 82 tempitem.flags|=item_flag1;
7572 82 }
7573
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.family == itype_wand)
7574 82 tempitem.flags|=item_flag1;
7575
2/2
✓ Branch 0 taken 20746 times.
✓ Branch 1 taken 82 times.
20828 else if(tempitem.family == itype_book)
7576 {
7577 82 tempitem.flags|=item_flag1;
7578 82 tempitem.power = 2;
7579 82 }
7580 20992 }
7581
7582
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 14) // August 2007
7583 {
7584
2/2
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
20992 if(tempitem.family == itype_fairy)
7585 {
7586 164 tempitem.usesound = WAV_SCALE;
7587
7588
1/2
✓ Branch 0 taken 164 times.
✗ Branch 1 not taken.
164 if(tempitem.fam_type)
7589 164 tempitem.misc3=50;
7590 164 }
7591
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.family == itype_potion)
7592 {
7593 164 tempitem.flags |= item_gain_old;
7594 164 }
7595 20992 }
7596
7597
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 17) // November 2007
7598 {
7599
3/4
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
✓ Branch 2 taken 164 times.
✗ Branch 3 not taken.
20992 if(tempitem.family == itype_candle && !tempitem.wpn3)
7600 {
7601 tempitem.wpn3 = wFIRE;
7602 }
7603
4/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 20746 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 82 times.
20992 else if(tempitem.family == itype_arrow && tempitem.power>4)
7604 {
7605 82 tempitem.flags|=item_flag1;
7606 82 }
7607 20992 }
7608
7609
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 18) // New Year's Eve 2007
7610 {
7611
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_whistle)
7612 82 tempitem.misc2 = 8; // Use the Whistle warp ring
7613
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.family == itype_bait)
7614 82 tempitem.misc1 = 768; // Frames until it goes
7615
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.family == itype_triforcepiece)
7616 {
7617
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
164 if(tempitem.flags & item_gamedata)
7618 {
7619 82 tempitem.misc2 = 1; // Cutscene 1
7620 82 tempitem.flags |= item_flag1; // Side Warp Out
7621 82 }
7622 164 }
7623 20992 }
7624
7625
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 19) // January 2008
7626 {
7627
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divineprotection)
7628 {
7629
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 80 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)) tempitem.flags |= item_flag3;
7630
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 72 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)) tempitem.flags |= item_flag4;
7631 82 }
7632 20992 }
7633
7634
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 20) // October 2008
7635 {
7636
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divineprotection)
7637 {
7638 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7639 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7640 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7641 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7642 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7643 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7644 82 }
7645 20992 }
7646
7647
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 21) // November 2008
7648 {
7649
1/2
✓ Branch 0 taken 20992 times.
✗ Branch 1 not taken.
20992 if(tempitem.flags & 0x0100) // item_slash
7650 {
7651 tempitem.flags &= ~item_unused;
7652
7653 if(tempitem.family == itype_sword ||
7654 tempitem.family == itype_wand ||
7655 tempitem.family == itype_candle ||
7656 tempitem.family == itype_cbyrna)
7657 {
7658 tempitem.flags |= item_flag4;
7659 }
7660 }
7661 20992 }
7662
7663
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 22) // September 2009
7664 {
7665
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7666 {
7667 164 tempitem.misc3 = tempitem.power/2;
7668 164 }
7669 20992 }
7670
7671
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 23) // March 2011
7672 {
7673
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_divinefire)
7674 82 tempitem.wpn5 = wFIRE;
7675
2/2
✓ Branch 0 taken 20828 times.
✓ Branch 1 taken 82 times.
20910 else if(tempitem.family == itype_book)
7676 82 tempitem.wpn2 = wFIRE;
7677 20992 }
7678
7679 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7680 // whether it was or not, and a lot of existing quests depended on the
7681 // incorrect behavior.
7682
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 25) // January 2012
7683 {
7684
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 328 times.
20992 if(tempitem.family == itype_bombbag)
7685 328 tempitem.flags |= item_flag1;
7686
7687
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divinefire)
7688 82 tempitem.flags |= item_flag3; // Sideview gravity flag
7689 20992 }
7690
7691
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 73472 times.
119296 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7692 {
7693
60/60
✓ Branch 0 taken 17688 times.
✓ Branch 1 taken 859 times.
✓ Branch 2 taken 844 times.
✓ Branch 3 taken 610 times.
✓ Branch 4 taken 332 times.
✓ Branch 5 taken 287 times.
✓ Branch 6 taken 568 times.
✓ Branch 7 taken 623 times.
✓ Branch 8 taken 302 times.
✓ Branch 9 taken 932 times.
✓ Branch 10 taken 907 times.
✓ Branch 11 taken 565 times.
✓ Branch 12 taken 873 times.
✓ Branch 13 taken 568 times.
✓ Branch 14 taken 284 times.
✓ Branch 15 taken 568 times.
✓ Branch 16 taken 300 times.
✓ Branch 17 taken 284 times.
✓ Branch 18 taken 861 times.
✓ Branch 19 taken 287 times.
✓ Branch 20 taken 290 times.
✓ Branch 21 taken 570 times.
✓ Branch 22 taken 260 times.
✓ Branch 23 taken 287 times.
✓ Branch 24 taken 284 times.
✓ Branch 25 taken 284 times.
✓ Branch 26 taken 284 times.
✓ Branch 27 taken 300 times.
✓ Branch 28 taken 286 times.
✓ Branch 29 taken 287 times.
✓ Branch 30 taken 284 times.
✓ Branch 31 taken 289 times.
✓ Branch 32 taken 568 times.
✓ Branch 33 taken 1136 times.
✓ Branch 34 taken 785 times.
✓ Branch 35 taken 284 times.
✓ Branch 36 taken 555 times.
✓ Branch 37 taken 1136 times.
✓ Branch 38 taken 284 times.
✓ Branch 39 taken 284 times.
✓ Branch 40 taken 284 times.
✓ Branch 41 taken 284 times.
✓ Branch 42 taken 284 times.
✓ Branch 43 taken 571 times.
✓ Branch 44 taken 568 times.
✓ Branch 45 taken 284 times.
✓ Branch 46 taken 855 times.
✓ Branch 47 taken 858 times.
✓ Branch 48 taken 1148 times.
✓ Branch 49 taken 284 times.
✓ Branch 50 taken 284 times.
✓ Branch 51 taken 284 times.
✓ Branch 52 taken 284 times.
✓ Branch 53 taken 284 times.
✓ Branch 54 taken 311 times.
✓ Branch 55 taken 10996 times.
✓ Branch 56 taken 2923 times.
✓ Branch 57 taken 857 times.
✓ Branch 58 taken 3317 times.
✓ Branch 59 taken 11233 times.
73472 switch(tempitem.family)
7694 {
7695 case itype_sword:
7696 {
7697 17688 tempitem.flags &= ~(item_flag5);
7698 17688 tempitem.misc3 = 0;
7699 17688 tempitem.misc4 = 0;
7700 17688 tempitem.misc5 = 0;
7701 17688 tempitem.misc6 = 0;
7702 17688 tempitem.misc7 = 0;
7703 17688 tempitem.misc8 = 0;
7704 17688 tempitem.misc9 = 0;
7705 17688 tempitem.misc10 = 0;
7706 17688 tempitem.wpn4 = 0;
7707 17688 tempitem.wpn5 = 0;
7708 17688 tempitem.wpn6 = 0;
7709 17688 tempitem.wpn7 = 0;
7710 17688 tempitem.wpn8 = 0;
7711 17688 tempitem.wpn9 = 0;
7712 17688 tempitem.wpn10 = 0;
7713 17688 break;
7714 }
7715 case itype_brang:
7716 {
7717 859 tempitem.flags &= ~(item_flag4 | item_flag5);
7718 859 tempitem.misc2 = 0;
7719 859 tempitem.misc5 = 0;
7720 859 tempitem.misc6 = 0;
7721 859 tempitem.misc7 = 0;
7722 859 tempitem.misc8 = 0;
7723 859 tempitem.misc9 = 0;
7724 859 tempitem.misc10 = 0;
7725 859 tempitem.wpn4 = 0;
7726 859 tempitem.wpn5 = 0;
7727 859 tempitem.wpn6 = 0;
7728 859 tempitem.wpn7 = 0;
7729 859 tempitem.wpn8 = 0;
7730 859 tempitem.wpn9 = 0;
7731 859 tempitem.wpn10 = 0;
7732 859 break;
7733 }
7734 case itype_arrow:
7735 {
7736 844 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
7737 844 tempitem.misc2 = 0;
7738 844 tempitem.misc3 = 0;
7739 844 tempitem.misc4 = 0;
7740 844 tempitem.misc5 = 0;
7741 844 tempitem.misc6 = 0;
7742 844 tempitem.misc7 = 0;
7743 844 tempitem.misc8 = 0;
7744 844 tempitem.misc9 = 0;
7745 844 tempitem.misc10 = 0;
7746 844 tempitem.wpn4 = 0;
7747 844 tempitem.wpn5 = 0;
7748 844 tempitem.wpn6 = 0;
7749 844 tempitem.wpn7 = 0;
7750 844 tempitem.wpn8 = 0;
7751 844 tempitem.wpn9 = 0;
7752 844 tempitem.wpn10 = 0;
7753 844 break;
7754 }
7755 case itype_candle:
7756 {
7757 610 tempitem.flags &= ~ (item_flag3 | item_flag5);
7758 610 tempitem.misc1 = 0;
7759 610 tempitem.misc2 = 0;
7760 610 tempitem.misc3 = 0;
7761 610 tempitem.misc4 = 0;
7762 610 tempitem.misc5 = 0;
7763 610 tempitem.misc6 = 0;
7764 610 tempitem.misc7 = 0;
7765 610 tempitem.misc8 = 0;
7766 610 tempitem.misc9 = 0;
7767 610 tempitem.misc10 = 0;
7768 610 tempitem.wpn4 = 0;
7769 610 tempitem.wpn5 = 0;
7770 610 tempitem.wpn6 = 0;
7771 610 tempitem.wpn7 = 0;
7772 610 tempitem.wpn8 = 0;
7773 610 tempitem.wpn9 = 0;
7774 610 tempitem.wpn10 = 0;
7775 610 break;
7776 }
7777 case itype_whistle:
7778 {
7779 332 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
7780 332 tempitem.misc3 = 0;
7781 332 tempitem.misc4 = 0;
7782 332 tempitem.misc5 = 0;
7783 332 tempitem.misc6 = 0;
7784 332 tempitem.misc7 = 0;
7785 332 tempitem.misc8 = 0;
7786 332 tempitem.misc9 = 0;
7787 332 tempitem.misc10 = 0;
7788 332 tempitem.wpn2 = 0;
7789 332 tempitem.wpn3 = 0;
7790 332 tempitem.wpn4 = 0;
7791 332 tempitem.wpn5 = 0;
7792 332 tempitem.wpn6 = 0;
7793 332 tempitem.wpn7 = 0;
7794 332 tempitem.wpn8 = 0;
7795 332 tempitem.wpn9 = 0;
7796 332 tempitem.wpn10 = 0;
7797 332 break;
7798 }
7799 case itype_bait:
7800 {
7801 287 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7802 287 tempitem.misc2 = 0;
7803 287 tempitem.misc3 = 0;
7804 287 tempitem.misc4 = 0;
7805 287 tempitem.misc5 = 0;
7806 287 tempitem.misc6 = 0;
7807 287 tempitem.misc7 = 0;
7808 287 tempitem.misc8 = 0;
7809 287 tempitem.misc9 = 0;
7810 287 tempitem.misc10 = 0;
7811 287 tempitem.wpn2 = 0;
7812 287 tempitem.wpn3 = 0;
7813 287 tempitem.wpn4 = 0;
7814 287 tempitem.wpn5 = 0;
7815 287 tempitem.wpn6 = 0;
7816 287 tempitem.wpn7 = 0;
7817 287 tempitem.wpn8 = 0;
7818 287 tempitem.wpn9 = 0;
7819 287 tempitem.wpn10 = 0;
7820 287 break;
7821 }
7822 case itype_letter:
7823 {
7824 568 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7825 568 tempitem.misc1 = 0;
7826 568 tempitem.misc2 = 0;
7827 568 tempitem.misc3 = 0;
7828 568 tempitem.misc4 = 0;
7829 568 tempitem.misc5 = 0;
7830 568 tempitem.misc6 = 0;
7831 568 tempitem.misc7 = 0;
7832 568 tempitem.misc8 = 0;
7833 568 tempitem.misc9 = 0;
7834 568 tempitem.misc10 = 0;
7835 568 tempitem.wpn = 0;
7836 568 tempitem.wpn2 = 0;
7837 568 tempitem.wpn3 = 0;
7838 568 tempitem.wpn4 = 0;
7839 568 tempitem.wpn5 = 0;
7840 568 tempitem.wpn6 = 0;
7841 568 tempitem.wpn7 = 0;
7842 568 tempitem.wpn8 = 0;
7843 568 tempitem.wpn9 = 0;
7844 568 tempitem.wpn10 = 0;
7845 568 break;
7846 }
7847 case itype_potion:
7848 {
7849 623 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
7850 623 tempitem.misc3 = 0;
7851 623 tempitem.misc4 = 0;
7852 623 tempitem.misc5 = 0;
7853 623 tempitem.misc6 = 0;
7854 623 tempitem.misc7 = 0;
7855 623 tempitem.misc8 = 0;
7856 623 tempitem.misc9 = 0;
7857 623 tempitem.misc10 = 0;
7858 623 tempitem.wpn = 0;
7859 623 tempitem.wpn2 = 0;
7860 623 tempitem.wpn3 = 0;
7861 623 tempitem.wpn4 = 0;
7862 623 tempitem.wpn5 = 0;
7863 623 tempitem.wpn6 = 0;
7864 623 tempitem.wpn7 = 0;
7865 623 tempitem.wpn8 = 0;
7866 623 tempitem.wpn9 = 0;
7867 623 tempitem.wpn10 = 0;
7868 623 break;
7869 }
7870 case itype_wand:
7871 {
7872 302 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
7873 302 tempitem.misc1 = 0;
7874 302 tempitem.misc2 = 0;
7875 302 tempitem.misc3 = 0;
7876 302 tempitem.misc4 = 0;
7877 302 tempitem.misc5 = 0;
7878 302 tempitem.misc6 = 0;
7879 302 tempitem.misc7 = 0;
7880 302 tempitem.misc8 = 0;
7881 302 tempitem.misc9 = 0;
7882 302 tempitem.misc10 = 0;
7883 302 tempitem.wpn4 = 0;
7884 302 tempitem.wpn5 = 0;
7885 302 tempitem.wpn6 = 0;
7886 302 tempitem.wpn7 = 0;
7887 302 tempitem.wpn8 = 0;
7888 302 tempitem.wpn9 = 0;
7889 302 tempitem.wpn10 = 0;
7890 302 break;
7891 }
7892 case itype_ring:
7893 {
7894 932 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7895 932 tempitem.misc2 = 0;
7896 932 tempitem.misc3 = 0;
7897 932 tempitem.misc4 = 0;
7898 932 tempitem.misc5 = 0;
7899 932 tempitem.misc6 = 0;
7900 932 tempitem.misc7 = 0;
7901 932 tempitem.misc8 = 0;
7902 932 tempitem.misc9 = 0;
7903 932 tempitem.misc10 = 0;
7904 932 tempitem.wpn = 0;
7905 932 tempitem.wpn2 = 0;
7906 932 tempitem.wpn3 = 0;
7907 932 tempitem.wpn4 = 0;
7908 932 tempitem.wpn5 = 0;
7909 932 tempitem.wpn6 = 0;
7910 932 tempitem.wpn7 = 0;
7911 932 tempitem.wpn8 = 0;
7912 932 tempitem.wpn9 = 0;
7913 932 tempitem.wpn10 = 0;
7914 932 break;
7915 }
7916 case itype_wallet:
7917 {
7918 907 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7919 907 tempitem.misc3 = 0;
7920 907 tempitem.misc4 = 0;
7921 907 tempitem.misc5 = 0;
7922 907 tempitem.misc6 = 0;
7923 907 tempitem.misc7 = 0;
7924 907 tempitem.misc8 = 0;
7925 907 tempitem.misc9 = 0;
7926 907 tempitem.misc10 = 0;
7927 907 tempitem.wpn = 0;
7928 907 tempitem.wpn2 = 0;
7929 907 tempitem.wpn3 = 0;
7930 907 tempitem.wpn4 = 0;
7931 907 tempitem.wpn5 = 0;
7932 907 tempitem.wpn6 = 0;
7933 907 tempitem.wpn7 = 0;
7934 907 tempitem.wpn8 = 0;
7935 907 tempitem.wpn9 = 0;
7936 907 tempitem.wpn10 = 0;
7937 907 break;
7938 }
7939 case itype_amulet:
7940 {
7941 565 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7942 565 tempitem.misc1 = 0;
7943 565 tempitem.misc2 = 0;
7944 565 tempitem.misc3 = 0;
7945 565 tempitem.misc4 = 0;
7946 565 tempitem.misc5 = 0;
7947 565 tempitem.misc6 = 0;
7948 565 tempitem.misc7 = 0;
7949 565 tempitem.misc8 = 0;
7950 565 tempitem.misc9 = 0;
7951 565 tempitem.misc10 = 0;
7952 565 tempitem.wpn = 0;
7953 565 tempitem.wpn2 = 0;
7954 565 tempitem.wpn3 = 0;
7955 565 tempitem.wpn4 = 0;
7956 565 tempitem.wpn5 = 0;
7957 565 tempitem.wpn6 = 0;
7958 565 tempitem.wpn7 = 0;
7959 565 tempitem.wpn8 = 0;
7960 565 tempitem.wpn9 = 0;
7961 565 tempitem.wpn10 = 0;
7962 565 break;
7963 }
7964 case itype_shield:
7965 {
7966 873 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7967 873 tempitem.misc3 = 0;
7968 873 tempitem.misc4 = 0;
7969 873 tempitem.misc5 = 0;
7970 873 tempitem.misc6 = 0;
7971 873 tempitem.misc7 = 0;
7972 873 tempitem.misc8 = 0;
7973 873 tempitem.misc9 = 0;
7974 873 tempitem.misc10 = 0;
7975 873 tempitem.wpn = 0;
7976 873 tempitem.wpn2 = 0;
7977 873 tempitem.wpn3 = 0;
7978 873 tempitem.wpn4 = 0;
7979 873 tempitem.wpn5 = 0;
7980 873 tempitem.wpn6 = 0;
7981 873 tempitem.wpn7 = 0;
7982 873 tempitem.wpn8 = 0;
7983 873 tempitem.wpn9 = 0;
7984 873 tempitem.wpn10 = 0;
7985 873 break;
7986 }
7987 case itype_bow:
7988 {
7989 568 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7990 568 tempitem.misc1 = 0;
7991 568 tempitem.misc2 = 0;
7992 568 tempitem.misc3 = 0;
7993 568 tempitem.misc4 = 0;
7994 568 tempitem.misc5 = 0;
7995 568 tempitem.misc6 = 0;
7996 568 tempitem.misc7 = 0;
7997 568 tempitem.misc8 = 0;
7998 568 tempitem.misc9 = 0;
7999 568 tempitem.misc10 = 0;
8000 568 tempitem.wpn = 0;
8001 568 tempitem.wpn2 = 0;
8002 568 tempitem.wpn3 = 0;
8003 568 tempitem.wpn4 = 0;
8004 568 tempitem.wpn5 = 0;
8005 568 tempitem.wpn6 = 0;
8006 568 tempitem.wpn7 = 0;
8007 568 tempitem.wpn8 = 0;
8008 568 tempitem.wpn9 = 0;
8009 568 tempitem.wpn10 = 0;
8010 568 break;
8011 }
8012 case itype_raft:
8013 {
8014 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8015 284 tempitem.misc1 = 0;
8016 284 tempitem.misc2 = 0;
8017 284 tempitem.misc3 = 0;
8018 284 tempitem.misc4 = 0;
8019 284 tempitem.misc5 = 0;
8020 284 tempitem.misc6 = 0;
8021 284 tempitem.misc7 = 0;
8022 284 tempitem.misc8 = 0;
8023 284 tempitem.misc9 = 0;
8024 284 tempitem.misc10 = 0;
8025 284 tempitem.wpn = 0;
8026 284 tempitem.wpn2 = 0;
8027 284 tempitem.wpn3 = 0;
8028 284 tempitem.wpn4 = 0;
8029 284 tempitem.wpn5 = 0;
8030 284 tempitem.wpn6 = 0;
8031 284 tempitem.wpn7 = 0;
8032 284 tempitem.wpn8 = 0;
8033 284 tempitem.wpn9 = 0;
8034 284 tempitem.wpn10 = 0;
8035 284 break;
8036 }
8037 case itype_ladder:
8038 {
8039 568 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8040 568 tempitem.misc1 = 0;
8041 568 tempitem.misc2 = 0;
8042 568 tempitem.misc3 = 0;
8043 568 tempitem.misc4 = 0;
8044 568 tempitem.misc5 = 0;
8045 568 tempitem.misc6 = 0;
8046 568 tempitem.misc7 = 0;
8047 568 tempitem.misc8 = 0;
8048 568 tempitem.misc9 = 0;
8049 568 tempitem.misc10 = 0;
8050 568 tempitem.wpn = 0;
8051 568 tempitem.wpn2 = 0;
8052 568 tempitem.wpn3 = 0;
8053 568 tempitem.wpn4 = 0;
8054 568 tempitem.wpn5 = 0;
8055 568 tempitem.wpn6 = 0;
8056 568 tempitem.wpn7 = 0;
8057 568 tempitem.wpn8 = 0;
8058 568 tempitem.wpn9 = 0;
8059 568 tempitem.wpn10 = 0;
8060 568 break;
8061 }
8062 case itype_book:
8063 {
8064 300 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8065 300 tempitem.misc1 = 0;
8066 300 tempitem.misc2 = 0;
8067 300 tempitem.misc3 = 0;
8068 300 tempitem.misc4 = 0;
8069 300 tempitem.misc5 = 0;
8070 300 tempitem.misc6 = 0;
8071 300 tempitem.misc7 = 0;
8072 300 tempitem.misc8 = 0;
8073 300 tempitem.misc9 = 0;
8074 300 tempitem.misc10 = 0;
8075 300 tempitem.wpn3 = 0;
8076 300 tempitem.wpn4 = 0;
8077 300 tempitem.wpn5 = 0;
8078 300 tempitem.wpn6 = 0;
8079 300 tempitem.wpn7 = 0;
8080 300 tempitem.wpn8 = 0;
8081 300 tempitem.wpn9 = 0;
8082 300 tempitem.wpn10 = 0;
8083 300 break;
8084 }
8085 case itype_magickey:
8086 {
8087 284 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8088 284 tempitem.misc1 = 0;
8089 284 tempitem.misc2 = 0;
8090 284 tempitem.misc3 = 0;
8091 284 tempitem.misc4 = 0;
8092 284 tempitem.misc5 = 0;
8093 284 tempitem.misc6 = 0;
8094 284 tempitem.misc7 = 0;
8095 284 tempitem.misc8 = 0;
8096 284 tempitem.misc9 = 0;
8097 284 tempitem.misc10 = 0;
8098 284 tempitem.wpn = 0;
8099 284 tempitem.wpn2 = 0;
8100 284 tempitem.wpn3 = 0;
8101 284 tempitem.wpn4 = 0;
8102 284 tempitem.wpn5 = 0;
8103 284 tempitem.wpn6 = 0;
8104 284 tempitem.wpn7 = 0;
8105 284 tempitem.wpn8 = 0;
8106 284 tempitem.wpn9 = 0;
8107 284 tempitem.wpn10 = 0;
8108 284 break;
8109 }
8110 case itype_bracelet:
8111 {
8112 861 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8113 861 tempitem.misc1 = 0;
8114 861 tempitem.misc2 = 0;
8115 861 tempitem.misc3 = 0;
8116 861 tempitem.misc4 = 0;
8117 861 tempitem.misc5 = 0;
8118 861 tempitem.misc6 = 0;
8119 861 tempitem.misc7 = 0;
8120 861 tempitem.misc8 = 0;
8121 861 tempitem.misc9 = 0;
8122 861 tempitem.misc10 = 0;
8123 861 tempitem.wpn = 0;
8124 861 tempitem.wpn2 = 0;
8125 861 tempitem.wpn3 = 0;
8126 861 tempitem.wpn4 = 0;
8127 861 tempitem.wpn5 = 0;
8128 861 tempitem.wpn6 = 0;
8129 861 tempitem.wpn7 = 0;
8130 861 tempitem.wpn8 = 0;
8131 861 tempitem.wpn9 = 0;
8132 861 tempitem.wpn10 = 0;
8133 861 break;
8134 }
8135 case itype_flippers:
8136 {
8137 287 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8138 287 tempitem.misc1 = 0;
8139 287 tempitem.misc2 = 0;
8140 287 tempitem.misc3 = 0;
8141 287 tempitem.misc4 = 0;
8142 287 tempitem.misc5 = 0;
8143 287 tempitem.misc6 = 0;
8144 287 tempitem.misc7 = 0;
8145 287 tempitem.misc8 = 0;
8146 287 tempitem.misc9 = 0;
8147 287 tempitem.misc10 = 0;
8148 287 tempitem.wpn = 0;
8149 287 tempitem.wpn2 = 0;
8150 287 tempitem.wpn3 = 0;
8151 287 tempitem.wpn4 = 0;
8152 287 tempitem.wpn5 = 0;
8153 287 tempitem.wpn6 = 0;
8154 287 tempitem.wpn7 = 0;
8155 287 tempitem.wpn8 = 0;
8156 287 tempitem.wpn9 = 0;
8157 287 tempitem.wpn10 = 0;
8158 287 break;
8159 }
8160 case itype_boots:
8161 {
8162 290 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8163 290 tempitem.misc1 = 0;
8164 290 tempitem.misc2 = 0;
8165 290 tempitem.misc3 = 0;
8166 290 tempitem.misc4 = 0;
8167 290 tempitem.misc5 = 0;
8168 290 tempitem.misc6 = 0;
8169 290 tempitem.misc7 = 0;
8170 290 tempitem.misc8 = 0;
8171 290 tempitem.misc9 = 0;
8172 290 tempitem.misc10 = 0;
8173 290 tempitem.wpn = 0;
8174 290 tempitem.wpn2 = 0;
8175 290 tempitem.wpn3 = 0;
8176 290 tempitem.wpn4 = 0;
8177 290 tempitem.wpn5 = 0;
8178 290 tempitem.wpn6 = 0;
8179 290 tempitem.wpn7 = 0;
8180 290 tempitem.wpn8 = 0;
8181 290 tempitem.wpn9 = 0;
8182 290 tempitem.wpn10 = 0;
8183 290 break;
8184 }
8185 case itype_hookshot:
8186 {
8187 570 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8188 570 tempitem.misc5 = 0;
8189 570 tempitem.misc6 = 0;
8190 570 tempitem.misc7 = 0;
8191 570 tempitem.misc8 = 0;
8192 570 tempitem.misc9 = 0;
8193 570 tempitem.misc10 = 0;
8194 570 tempitem.wpn5 = 0;
8195 570 tempitem.wpn6 = 0;
8196 570 tempitem.wpn7 = 0;
8197 570 tempitem.wpn8 = 0;
8198 570 tempitem.wpn9 = 0;
8199 570 tempitem.wpn10 = 0;
8200 570 break;
8201 }
8202 case itype_lens:
8203 {
8204 260 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8205 260 tempitem.misc2 = 0;
8206 260 tempitem.misc3 = 0;
8207 260 tempitem.misc4 = 0;
8208 260 tempitem.misc5 = 0;
8209 260 tempitem.misc6 = 0;
8210 260 tempitem.misc7 = 0;
8211 260 tempitem.misc8 = 0;
8212 260 tempitem.misc9 = 0;
8213 260 tempitem.misc10 = 0;
8214 260 tempitem.wpn = 0;
8215 260 tempitem.wpn2 = 0;
8216 260 tempitem.wpn3 = 0;
8217 260 tempitem.wpn4 = 0;
8218 260 tempitem.wpn5 = 0;
8219 260 tempitem.wpn6 = 0;
8220 260 tempitem.wpn7 = 0;
8221 260 tempitem.wpn8 = 0;
8222 260 tempitem.wpn9 = 0;
8223 260 tempitem.wpn10 = 0;
8224 260 break;
8225 }
8226 case itype_hammer:
8227 {
8228 287 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8229 287 tempitem.misc1 = 0;
8230 287 tempitem.misc2 = 0;
8231 287 tempitem.misc3 = 0;
8232 287 tempitem.misc4 = 0;
8233 287 tempitem.misc5 = 0;
8234 287 tempitem.misc6 = 0;
8235 287 tempitem.misc7 = 0;
8236 287 tempitem.misc8 = 0;
8237 287 tempitem.misc9 = 0;
8238 287 tempitem.misc10 = 0;
8239 287 tempitem.wpn3 = 0;
8240 287 tempitem.wpn4 = 0;
8241 287 tempitem.wpn5 = 0;
8242 287 tempitem.wpn6 = 0;
8243 287 tempitem.wpn7 = 0;
8244 287 tempitem.wpn8 = 0;
8245 287 tempitem.wpn9 = 0;
8246 287 tempitem.wpn10 = 0;
8247 287 break;
8248 }
8249 case itype_divinefire:
8250 {
8251 284 tempitem.flags &= ~ (item_flag1 | item_flag4 | item_flag5);
8252 284 tempitem.misc3 = 0;
8253 284 tempitem.misc4 = 0;
8254 284 tempitem.misc5 = 0;
8255 284 tempitem.misc6 = 0;
8256 284 tempitem.misc7 = 0;
8257 284 tempitem.misc8 = 0;
8258 284 tempitem.misc9 = 0;
8259 284 tempitem.misc10 = 0;
8260 284 tempitem.wpn6 = 0;
8261 284 tempitem.wpn7 = 0;
8262 284 tempitem.wpn8 = 0;
8263 284 tempitem.wpn9 = 0;
8264 284 tempitem.wpn10 = 0;
8265 284 break;
8266 }
8267 case itype_divineescape:
8268 {
8269 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8270 284 tempitem.misc2 = 0;
8271 284 tempitem.misc3 = 0;
8272 284 tempitem.misc4 = 0;
8273 284 tempitem.misc5 = 0;
8274 284 tempitem.misc6 = 0;
8275 284 tempitem.misc7 = 0;
8276 284 tempitem.misc8 = 0;
8277 284 tempitem.misc9 = 0;
8278 284 tempitem.misc10 = 0;
8279 284 tempitem.wpn = 0;
8280 284 tempitem.wpn2 = 0;
8281 284 tempitem.wpn3 = 0;
8282 284 tempitem.wpn4 = 0;
8283 284 tempitem.wpn5 = 0;
8284 284 tempitem.wpn6 = 0;
8285 284 tempitem.wpn7 = 0;
8286 284 tempitem.wpn8 = 0;
8287 284 tempitem.wpn9 = 0;
8288 284 tempitem.wpn10 = 0;
8289 284 break;
8290 }
8291 case itype_divineprotection:
8292 {
8293 284 tempitem.flags &= ~ (item_flag5);
8294 284 tempitem.misc2 = 0;
8295 284 tempitem.misc3 = 0;
8296 284 tempitem.misc4 = 0;
8297 284 tempitem.misc5 = 0;
8298 284 tempitem.misc6 = 0;
8299 284 tempitem.misc7 = 0;
8300 284 tempitem.misc8 = 0;
8301 284 tempitem.misc9 = 0;
8302 284 tempitem.misc10 = 0;
8303 284 break;
8304 }
8305 case itype_bomb:
8306 {
8307 300 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8308 300 tempitem.misc4 = 0;
8309 300 tempitem.misc5 = 0;
8310 300 tempitem.misc6 = 0;
8311 300 tempitem.misc7 = 0;
8312 300 tempitem.misc8 = 0;
8313 300 tempitem.misc9 = 0;
8314 300 tempitem.misc10 = 0;
8315 300 tempitem.wpn3 = 0;
8316 300 tempitem.wpn4 = 0;
8317 300 tempitem.wpn5 = 0;
8318 300 tempitem.wpn6 = 0;
8319 300 tempitem.wpn7 = 0;
8320 300 tempitem.wpn8 = 0;
8321 300 tempitem.wpn9 = 0;
8322 300 tempitem.wpn10 = 0;
8323 300 break;
8324 }
8325 case itype_sbomb:
8326 {
8327 286 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8328 286 tempitem.misc4 = 0;
8329 286 tempitem.misc5 = 0;
8330 286 tempitem.misc6 = 0;
8331 286 tempitem.misc7 = 0;
8332 286 tempitem.misc8 = 0;
8333 286 tempitem.misc9 = 0;
8334 286 tempitem.misc10 = 0;
8335 286 tempitem.wpn3 = 0;
8336 286 tempitem.wpn4 = 0;
8337 286 tempitem.wpn5 = 0;
8338 286 tempitem.wpn6 = 0;
8339 286 tempitem.wpn7 = 0;
8340 286 tempitem.wpn8 = 0;
8341 286 tempitem.wpn9 = 0;
8342 286 tempitem.wpn10 = 0;
8343 286 break;
8344 }
8345 case itype_clock:
8346 {
8347 287 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8348 287 tempitem.misc2 = 0;
8349 287 tempitem.misc3 = 0;
8350 287 tempitem.misc4 = 0;
8351 287 tempitem.misc5 = 0;
8352 287 tempitem.misc6 = 0;
8353 287 tempitem.misc7 = 0;
8354 287 tempitem.misc8 = 0;
8355 287 tempitem.misc9 = 0;
8356 287 tempitem.misc10 = 0;
8357 287 tempitem.wpn = 0;
8358 287 tempitem.wpn2 = 0;
8359 287 tempitem.wpn3 = 0;
8360 287 tempitem.wpn4 = 0;
8361 287 tempitem.wpn5 = 0;
8362 287 tempitem.wpn6 = 0;
8363 287 tempitem.wpn7 = 0;
8364 287 tempitem.wpn8 = 0;
8365 287 tempitem.wpn9 = 0;
8366 287 tempitem.wpn10 = 0;
8367 287 break;
8368 }
8369 case itype_key:
8370 {
8371 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8372 284 tempitem.misc1 = 0;
8373 284 tempitem.misc2 = 0;
8374 284 tempitem.misc3 = 0;
8375 284 tempitem.misc4 = 0;
8376 284 tempitem.misc5 = 0;
8377 284 tempitem.misc6 = 0;
8378 284 tempitem.misc7 = 0;
8379 284 tempitem.misc8 = 0;
8380 284 tempitem.misc9 = 0;
8381 284 tempitem.misc10 = 0;
8382 284 tempitem.wpn = 0;
8383 284 tempitem.wpn2 = 0;
8384 284 tempitem.wpn3 = 0;
8385 284 tempitem.wpn4 = 0;
8386 284 tempitem.wpn5 = 0;
8387 284 tempitem.wpn6 = 0;
8388 284 tempitem.wpn7 = 0;
8389 284 tempitem.wpn8 = 0;
8390 284 tempitem.wpn9 = 0;
8391 284 tempitem.wpn10 = 0;
8392 284 break;
8393 }
8394 case itype_magiccontainer:
8395 {
8396 289 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8397 289 tempitem.misc1 = 0;
8398 289 tempitem.misc2 = 0;
8399 289 tempitem.misc3 = 0;
8400 289 tempitem.misc4 = 0;
8401 289 tempitem.misc5 = 0;
8402 289 tempitem.misc6 = 0;
8403 289 tempitem.misc7 = 0;
8404 289 tempitem.misc8 = 0;
8405 289 tempitem.misc9 = 0;
8406 289 tempitem.misc10 = 0;
8407 289 tempitem.wpn = 0;
8408 289 tempitem.wpn2 = 0;
8409 289 tempitem.wpn3 = 0;
8410 289 tempitem.wpn4 = 0;
8411 289 tempitem.wpn5 = 0;
8412 289 tempitem.wpn6 = 0;
8413 289 tempitem.wpn7 = 0;
8414 289 tempitem.wpn8 = 0;
8415 289 tempitem.wpn9 = 0;
8416 289 tempitem.wpn10 = 0;
8417 289 break;
8418 }
8419 case itype_triforcepiece:
8420 {
8421 568 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8422 568 tempitem.misc3 = 0;
8423 568 tempitem.misc4 = 0;
8424 568 tempitem.misc5 = 0;
8425 568 tempitem.misc6 = 0;
8426 568 tempitem.misc7 = 0;
8427 568 tempitem.misc8 = 0;
8428 568 tempitem.misc9 = 0;
8429 568 tempitem.misc10 = 0;
8430 568 tempitem.wpn = 0;
8431 568 tempitem.wpn2 = 0;
8432 568 tempitem.wpn3 = 0;
8433 568 tempitem.wpn4 = 0;
8434 568 tempitem.wpn5 = 0;
8435 568 tempitem.wpn6 = 0;
8436 568 tempitem.wpn7 = 0;
8437 568 tempitem.wpn8 = 0;
8438 568 tempitem.wpn9 = 0;
8439 568 tempitem.wpn10 = 0;
8440 568 break;
8441 }
8442 case itype_map: case itype_compass: case itype_bosskey:
8443 {
8444 857 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8445 857 tempitem.misc1 = 0;
8446 857 tempitem.misc2 = 0;
8447 857 tempitem.misc3 = 0;
8448 857 tempitem.misc4 = 0;
8449 857 tempitem.misc5 = 0;
8450 857 tempitem.misc6 = 0;
8451 857 tempitem.misc7 = 0;
8452 857 tempitem.misc8 = 0;
8453 857 tempitem.misc9 = 0;
8454 857 tempitem.misc10 = 0;
8455 857 tempitem.wpn = 0;
8456 857 tempitem.wpn2 = 0;
8457 857 tempitem.wpn3 = 0;
8458 857 tempitem.wpn4 = 0;
8459 857 tempitem.wpn5 = 0;
8460 857 tempitem.wpn6 = 0;
8461 857 tempitem.wpn7 = 0;
8462 857 tempitem.wpn8 = 0;
8463 857 tempitem.wpn9 = 0;
8464 857 tempitem.wpn10 = 0;
8465 857 break;
8466 }
8467 case itype_quiver:
8468 {
8469 1136 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8470 1136 tempitem.misc3 = 0;
8471 1136 tempitem.misc4 = 0;
8472 1136 tempitem.misc5 = 0;
8473 1136 tempitem.misc6 = 0;
8474 1136 tempitem.misc7 = 0;
8475 1136 tempitem.misc8 = 0;
8476 1136 tempitem.misc9 = 0;
8477 1136 tempitem.misc10 = 0;
8478 1136 tempitem.wpn = 0;
8479 1136 tempitem.wpn2 = 0;
8480 1136 tempitem.wpn3 = 0;
8481 1136 tempitem.wpn4 = 0;
8482 1136 tempitem.wpn5 = 0;
8483 1136 tempitem.wpn6 = 0;
8484 1136 tempitem.wpn7 = 0;
8485 1136 tempitem.wpn8 = 0;
8486 1136 tempitem.wpn9 = 0;
8487 1136 tempitem.wpn10 = 0;
8488 1136 break;
8489 }
8490 case itype_lkey:
8491 {
8492 785 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8493 785 tempitem.misc1 = 0;
8494 785 tempitem.misc2 = 0;
8495 785 tempitem.misc3 = 0;
8496 785 tempitem.misc4 = 0;
8497 785 tempitem.misc5 = 0;
8498 785 tempitem.misc6 = 0;
8499 785 tempitem.misc7 = 0;
8500 785 tempitem.misc8 = 0;
8501 785 tempitem.misc9 = 0;
8502 785 tempitem.misc10 = 0;
8503 785 tempitem.wpn = 0;
8504 785 tempitem.wpn2 = 0;
8505 785 tempitem.wpn3 = 0;
8506 785 tempitem.wpn4 = 0;
8507 785 tempitem.wpn5 = 0;
8508 785 tempitem.wpn6 = 0;
8509 785 tempitem.wpn7 = 0;
8510 785 tempitem.wpn8 = 0;
8511 785 tempitem.wpn9 = 0;
8512 785 tempitem.wpn10 = 0;
8513 785 break;
8514 }
8515 case itype_cbyrna:
8516 {
8517 284 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
8518 284 tempitem.misc4 = 0;
8519 284 tempitem.misc5 = 0;
8520 284 tempitem.misc6 = 0;
8521 284 tempitem.misc7 = 0;
8522 284 tempitem.misc8 = 0;
8523 284 tempitem.misc9 = 0;
8524 284 tempitem.misc10 = 0;
8525 284 tempitem.wpn6 = 0;
8526 284 tempitem.wpn7 = 0;
8527 284 tempitem.wpn8 = 0;
8528 284 tempitem.wpn9 = 0;
8529 284 tempitem.wpn10 = 0;
8530 284 break;
8531 }
8532 case itype_rupee: case itype_arrowammo:
8533 {
8534 3317 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8535 3317 tempitem.misc1 = 0;
8536 3317 tempitem.misc2 = 0;
8537 3317 tempitem.misc3 = 0;
8538 3317 tempitem.misc4 = 0;
8539 3317 tempitem.misc5 = 0;
8540 3317 tempitem.misc6 = 0;
8541 3317 tempitem.misc7 = 0;
8542 3317 tempitem.misc8 = 0;
8543 3317 tempitem.misc9 = 0;
8544 3317 tempitem.misc10 = 0;
8545 3317 tempitem.wpn = 0;
8546 3317 tempitem.wpn2 = 0;
8547 3317 tempitem.wpn3 = 0;
8548 3317 tempitem.wpn4 = 0;
8549 3317 tempitem.wpn5 = 0;
8550 3317 tempitem.wpn6 = 0;
8551 3317 tempitem.wpn7 = 0;
8552 3317 tempitem.wpn8 = 0;
8553 3317 tempitem.wpn9 = 0;
8554 3317 tempitem.wpn10 = 0;
8555 3317 break;
8556 }
8557 case itype_fairy:
8558 {
8559 555 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
8560 555 tempitem.misc4 = 0;
8561 555 tempitem.misc5 = 0;
8562 555 tempitem.misc6 = 0;
8563 555 tempitem.misc7 = 0;
8564 555 tempitem.misc8 = 0;
8565 555 tempitem.misc9 = 0;
8566 555 tempitem.misc10 = 0;
8567 555 tempitem.wpn = 0;
8568 555 tempitem.wpn2 = 0;
8569 555 tempitem.wpn3 = 0;
8570 555 tempitem.wpn4 = 0;
8571 555 tempitem.wpn5 = 0;
8572 555 tempitem.wpn6 = 0;
8573 555 tempitem.wpn7 = 0;
8574 555 tempitem.wpn8 = 0;
8575 555 tempitem.wpn9 = 0;
8576 555 tempitem.wpn10 = 0;
8577 555 break;
8578 }
8579 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8580 {
8581 2923 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8582 2923 tempitem.misc1 = 0;
8583 2923 tempitem.misc2 = 0;
8584 2923 tempitem.misc3 = 0;
8585 2923 tempitem.misc4 = 0;
8586 2923 tempitem.misc5 = 0;
8587 2923 tempitem.misc6 = 0;
8588 2923 tempitem.misc7 = 0;
8589 2923 tempitem.misc8 = 0;
8590 2923 tempitem.misc9 = 0;
8591 2923 tempitem.misc10 = 0;
8592 2923 tempitem.wpn = 0;
8593 2923 tempitem.wpn2 = 0;
8594 2923 tempitem.wpn3 = 0;
8595 2923 tempitem.wpn4 = 0;
8596 2923 tempitem.wpn5 = 0;
8597 2923 tempitem.wpn6 = 0;
8598 2923 tempitem.wpn7 = 0;
8599 2923 tempitem.wpn8 = 0;
8600 2923 tempitem.wpn9 = 0;
8601 2923 tempitem.wpn10 = 0;
8602 2923 break;
8603 }
8604 case itype_bombbag:
8605 {
8606 1136 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8607 1136 tempitem.misc3 = 0;
8608 1136 tempitem.misc4 = 0;
8609 1136 tempitem.misc5 = 0;
8610 1136 tempitem.misc6 = 0;
8611 1136 tempitem.misc7 = 0;
8612 1136 tempitem.misc8 = 0;
8613 1136 tempitem.misc9 = 0;
8614 1136 tempitem.misc10 = 0;
8615 1136 tempitem.wpn = 0;
8616 1136 tempitem.wpn2 = 0;
8617 1136 tempitem.wpn3 = 0;
8618 1136 tempitem.wpn4 = 0;
8619 1136 tempitem.wpn5 = 0;
8620 1136 tempitem.wpn6 = 0;
8621 1136 tempitem.wpn7 = 0;
8622 1136 tempitem.wpn8 = 0;
8623 1136 tempitem.wpn9 = 0;
8624 1136 tempitem.wpn10 = 0;
8625 1136 break;
8626 }
8627 case itype_rocs:
8628 {
8629 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8630 284 tempitem.misc1 = 0;
8631 284 tempitem.misc2 = 0;
8632 284 tempitem.misc3 = 0;
8633 284 tempitem.misc4 = 0;
8634 284 tempitem.misc5 = 0;
8635 284 tempitem.misc6 = 0;
8636 284 tempitem.misc7 = 0;
8637 284 tempitem.misc8 = 0;
8638 284 tempitem.misc9 = 0;
8639 284 tempitem.misc10 = 0;
8640 284 tempitem.wpn = 0;
8641 284 tempitem.wpn2 = 0;
8642 284 tempitem.wpn3 = 0;
8643 284 tempitem.wpn4 = 0;
8644 284 tempitem.wpn5 = 0;
8645 284 tempitem.wpn6 = 0;
8646 284 tempitem.wpn7 = 0;
8647 284 tempitem.wpn8 = 0;
8648 284 tempitem.wpn9 = 0;
8649 284 tempitem.wpn10 = 0;
8650 284 break;
8651 }
8652 case itype_hoverboots:
8653 {
8654 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8655 284 tempitem.misc2 = 0;
8656 284 tempitem.misc3 = 0;
8657 284 tempitem.misc4 = 0;
8658 284 tempitem.misc5 = 0;
8659 284 tempitem.misc6 = 0;
8660 284 tempitem.misc7 = 0;
8661 284 tempitem.misc8 = 0;
8662 284 tempitem.misc9 = 0;
8663 284 tempitem.misc10 = 0;
8664 284 tempitem.wpn2 = 0;
8665 284 tempitem.wpn3 = 0;
8666 284 tempitem.wpn4 = 0;
8667 284 tempitem.wpn5 = 0;
8668 284 tempitem.wpn6 = 0;
8669 284 tempitem.wpn7 = 0;
8670 284 tempitem.wpn8 = 0;
8671 284 tempitem.wpn9 = 0;
8672 284 tempitem.wpn10 = 0;
8673 284 break;
8674 }
8675 case itype_spinscroll:
8676 {
8677 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8678 284 tempitem.misc2 = 0;
8679 284 tempitem.misc3 = 0;
8680 284 tempitem.misc4 = 0;
8681 284 tempitem.misc5 = 0;
8682 284 tempitem.misc6 = 0;
8683 284 tempitem.misc7 = 0;
8684 284 tempitem.misc8 = 0;
8685 284 tempitem.misc9 = 0;
8686 284 tempitem.misc10 = 0;
8687 284 tempitem.wpn = 0;
8688 284 tempitem.wpn2 = 0;
8689 284 tempitem.wpn3 = 0;
8690 284 tempitem.wpn4 = 0;
8691 284 tempitem.wpn5 = 0;
8692 284 tempitem.wpn6 = 0;
8693 284 tempitem.wpn7 = 0;
8694 284 tempitem.wpn8 = 0;
8695 284 tempitem.wpn9 = 0;
8696 284 tempitem.wpn10 = 0;
8697 284 break;
8698 }
8699 case itype_crossscroll:
8700 {
8701 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8702 284 tempitem.misc1 = 0;
8703 284 tempitem.misc2 = 0;
8704 284 tempitem.misc3 = 0;
8705 284 tempitem.misc4 = 0;
8706 284 tempitem.misc5 = 0;
8707 284 tempitem.misc6 = 0;
8708 284 tempitem.misc7 = 0;
8709 284 tempitem.misc8 = 0;
8710 284 tempitem.misc9 = 0;
8711 284 tempitem.misc10 = 0;
8712 284 tempitem.wpn = 0;
8713 284 tempitem.wpn2 = 0;
8714 284 tempitem.wpn3 = 0;
8715 284 tempitem.wpn4 = 0;
8716 284 tempitem.wpn5 = 0;
8717 284 tempitem.wpn6 = 0;
8718 284 tempitem.wpn7 = 0;
8719 284 tempitem.wpn8 = 0;
8720 284 tempitem.wpn9 = 0;
8721 284 tempitem.wpn10 = 0;
8722 284 break;
8723 }
8724 case itype_quakescroll:
8725 {
8726 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8727 284 tempitem.misc3 = 0;
8728 284 tempitem.misc4 = 0;
8729 284 tempitem.misc5 = 0;
8730 284 tempitem.misc6 = 0;
8731 284 tempitem.misc7 = 0;
8732 284 tempitem.misc8 = 0;
8733 284 tempitem.misc9 = 0;
8734 284 tempitem.misc10 = 0;
8735 284 tempitem.wpn = 0;
8736 284 tempitem.wpn2 = 0;
8737 284 tempitem.wpn3 = 0;
8738 284 tempitem.wpn4 = 0;
8739 284 tempitem.wpn5 = 0;
8740 284 tempitem.wpn6 = 0;
8741 284 tempitem.wpn7 = 0;
8742 284 tempitem.wpn8 = 0;
8743 284 tempitem.wpn9 = 0;
8744 284 tempitem.wpn10 = 0;
8745 284 break;
8746 }
8747 case itype_whispring:
8748 {
8749 571 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8750 571 tempitem.misc2 = 0;
8751 571 tempitem.misc3 = 0;
8752 571 tempitem.misc4 = 0;
8753 571 tempitem.misc5 = 0;
8754 571 tempitem.misc6 = 0;
8755 571 tempitem.misc7 = 0;
8756 571 tempitem.misc8 = 0;
8757 571 tempitem.misc9 = 0;
8758 571 tempitem.misc10 = 0;
8759 571 tempitem.wpn = 0;
8760 571 tempitem.wpn2 = 0;
8761 571 tempitem.wpn3 = 0;
8762 571 tempitem.wpn4 = 0;
8763 571 tempitem.wpn5 = 0;
8764 571 tempitem.wpn6 = 0;
8765 571 tempitem.wpn7 = 0;
8766 571 tempitem.wpn8 = 0;
8767 571 tempitem.wpn9 = 0;
8768 571 tempitem.wpn10 = 0;
8769 571 break;
8770 }
8771 case itype_chargering:
8772 {
8773 568 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8774 568 tempitem.misc3 = 0;
8775 568 tempitem.misc4 = 0;
8776 568 tempitem.misc5 = 0;
8777 568 tempitem.misc6 = 0;
8778 568 tempitem.misc7 = 0;
8779 568 tempitem.misc8 = 0;
8780 568 tempitem.misc9 = 0;
8781 568 tempitem.misc10 = 0;
8782 568 tempitem.wpn = 0;
8783 568 tempitem.wpn2 = 0;
8784 568 tempitem.wpn3 = 0;
8785 568 tempitem.wpn4 = 0;
8786 568 tempitem.wpn5 = 0;
8787 568 tempitem.wpn6 = 0;
8788 568 tempitem.wpn7 = 0;
8789 568 tempitem.wpn8 = 0;
8790 568 tempitem.wpn9 = 0;
8791 568 tempitem.wpn10 = 0;
8792 568 break;
8793 }
8794 case itype_perilscroll:
8795 {
8796 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8797 284 tempitem.misc2 = 0;
8798 284 tempitem.misc3 = 0;
8799 284 tempitem.misc4 = 0;
8800 284 tempitem.misc5 = 0;
8801 284 tempitem.misc6 = 0;
8802 284 tempitem.misc7 = 0;
8803 284 tempitem.misc8 = 0;
8804 284 tempitem.misc9 = 0;
8805 284 tempitem.misc10 = 0;
8806 284 tempitem.wpn = 0;
8807 284 tempitem.wpn2 = 0;
8808 284 tempitem.wpn3 = 0;
8809 284 tempitem.wpn4 = 0;
8810 284 tempitem.wpn5 = 0;
8811 284 tempitem.wpn6 = 0;
8812 284 tempitem.wpn7 = 0;
8813 284 tempitem.wpn8 = 0;
8814 284 tempitem.wpn9 = 0;
8815 284 tempitem.wpn10 = 0;
8816 284 break;
8817 }
8818 case itype_wealthmedal:
8819 {
8820 855 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8821 855 tempitem.misc2 = 0;
8822 855 tempitem.misc3 = 0;
8823 855 tempitem.misc4 = 0;
8824 855 tempitem.misc5 = 0;
8825 855 tempitem.misc6 = 0;
8826 855 tempitem.misc7 = 0;
8827 855 tempitem.misc8 = 0;
8828 855 tempitem.misc9 = 0;
8829 855 tempitem.misc10 = 0;
8830 855 tempitem.wpn = 0;
8831 855 tempitem.wpn2 = 0;
8832 855 tempitem.wpn3 = 0;
8833 855 tempitem.wpn4 = 0;
8834 855 tempitem.wpn5 = 0;
8835 855 tempitem.wpn6 = 0;
8836 855 tempitem.wpn7 = 0;
8837 855 tempitem.wpn8 = 0;
8838 855 tempitem.wpn9 = 0;
8839 855 tempitem.wpn10 = 0;
8840 855 break;
8841 }
8842 case itype_heartring:
8843 {
8844 858 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8845 858 tempitem.misc3 = 0;
8846 858 tempitem.misc4 = 0;
8847 858 tempitem.misc5 = 0;
8848 858 tempitem.misc6 = 0;
8849 858 tempitem.misc7 = 0;
8850 858 tempitem.misc8 = 0;
8851 858 tempitem.misc9 = 0;
8852 858 tempitem.misc10 = 0;
8853 858 tempitem.wpn = 0;
8854 858 tempitem.wpn2 = 0;
8855 858 tempitem.wpn3 = 0;
8856 858 tempitem.wpn4 = 0;
8857 858 tempitem.wpn5 = 0;
8858 858 tempitem.wpn6 = 0;
8859 858 tempitem.wpn7 = 0;
8860 858 tempitem.wpn8 = 0;
8861 858 tempitem.wpn9 = 0;
8862 858 tempitem.wpn10 = 0;
8863 858 break;
8864 }
8865 case itype_magicring:
8866 {
8867 1148 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8868 1148 tempitem.misc3 = 0;
8869 1148 tempitem.misc4 = 0;
8870 1148 tempitem.misc5 = 0;
8871 1148 tempitem.misc6 = 0;
8872 1148 tempitem.misc7 = 0;
8873 1148 tempitem.misc8 = 0;
8874 1148 tempitem.misc9 = 0;
8875 1148 tempitem.misc10 = 0;
8876 1148 tempitem.wpn = 0;
8877 1148 tempitem.wpn2 = 0;
8878 1148 tempitem.wpn3 = 0;
8879 1148 tempitem.wpn4 = 0;
8880 1148 tempitem.wpn5 = 0;
8881 1148 tempitem.wpn6 = 0;
8882 1148 tempitem.wpn7 = 0;
8883 1148 tempitem.wpn8 = 0;
8884 1148 tempitem.wpn9 = 0;
8885 1148 tempitem.wpn10 = 0;
8886 1148 break;
8887 }
8888 case itype_spinscroll2:
8889 {
8890 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8891 284 tempitem.misc2 = 0;
8892 284 tempitem.misc3 = 0;
8893 284 tempitem.misc4 = 0;
8894 284 tempitem.misc5 = 0;
8895 284 tempitem.misc6 = 0;
8896 284 tempitem.misc7 = 0;
8897 284 tempitem.misc8 = 0;
8898 284 tempitem.misc9 = 0;
8899 284 tempitem.misc10 = 0;
8900 284 tempitem.wpn = 0;
8901 284 tempitem.wpn2 = 0;
8902 284 tempitem.wpn3 = 0;
8903 284 tempitem.wpn4 = 0;
8904 284 tempitem.wpn5 = 0;
8905 284 tempitem.wpn6 = 0;
8906 284 tempitem.wpn7 = 0;
8907 284 tempitem.wpn8 = 0;
8908 284 tempitem.wpn9 = 0;
8909 284 tempitem.wpn10 = 0;
8910 284 break;
8911 }
8912 case itype_quakescroll2:
8913 {
8914 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8915 284 tempitem.misc3 = 0;
8916 284 tempitem.misc4 = 0;
8917 284 tempitem.misc5 = 0;
8918 284 tempitem.misc6 = 0;
8919 284 tempitem.misc7 = 0;
8920 284 tempitem.misc8 = 0;
8921 284 tempitem.misc9 = 0;
8922 284 tempitem.misc10 = 0;
8923 284 tempitem.wpn = 0;
8924 284 tempitem.wpn2 = 0;
8925 284 tempitem.wpn3 = 0;
8926 284 tempitem.wpn4 = 0;
8927 284 tempitem.wpn5 = 0;
8928 284 tempitem.wpn6 = 0;
8929 284 tempitem.wpn7 = 0;
8930 284 tempitem.wpn8 = 0;
8931 284 tempitem.wpn9 = 0;
8932 284 tempitem.wpn10 = 0;
8933 284 break;
8934 }
8935 case itype_agony:
8936 {
8937 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8938 284 tempitem.misc2 = 0;
8939 284 tempitem.misc3 = 0;
8940 284 tempitem.misc4 = 0;
8941 284 tempitem.misc5 = 0;
8942 284 tempitem.misc6 = 0;
8943 284 tempitem.misc7 = 0;
8944 284 tempitem.misc8 = 0;
8945 284 tempitem.misc9 = 0;
8946 284 tempitem.misc10 = 0;
8947 284 tempitem.wpn = 0;
8948 284 tempitem.wpn2 = 0;
8949 284 tempitem.wpn3 = 0;
8950 284 tempitem.wpn4 = 0;
8951 284 tempitem.wpn5 = 0;
8952 284 tempitem.wpn6 = 0;
8953 284 tempitem.wpn7 = 0;
8954 284 tempitem.wpn8 = 0;
8955 284 tempitem.wpn9 = 0;
8956 284 tempitem.wpn10 = 0;
8957 284 break;
8958 }
8959 case itype_stompboots:
8960 {
8961 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8962 284 tempitem.misc1 = 0;
8963 284 tempitem.misc2 = 0;
8964 284 tempitem.misc3 = 0;
8965 284 tempitem.misc4 = 0;
8966 284 tempitem.misc5 = 0;
8967 284 tempitem.misc6 = 0;
8968 284 tempitem.misc7 = 0;
8969 284 tempitem.misc8 = 0;
8970 284 tempitem.misc9 = 0;
8971 284 tempitem.misc10 = 0;
8972 284 tempitem.wpn = 0;
8973 284 tempitem.wpn2 = 0;
8974 284 tempitem.wpn3 = 0;
8975 284 tempitem.wpn4 = 0;
8976 284 tempitem.wpn5 = 0;
8977 284 tempitem.wpn6 = 0;
8978 284 tempitem.wpn7 = 0;
8979 284 tempitem.wpn8 = 0;
8980 284 tempitem.wpn9 = 0;
8981 284 tempitem.wpn10 = 0;
8982 284 break;
8983 }
8984 case itype_whimsicalring:
8985 {
8986 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8987 284 tempitem.misc2 = 0;
8988 284 tempitem.misc3 = 0;
8989 284 tempitem.misc4 = 0;
8990 284 tempitem.misc5 = 0;
8991 284 tempitem.misc6 = 0;
8992 284 tempitem.misc7 = 0;
8993 284 tempitem.misc8 = 0;
8994 284 tempitem.misc9 = 0;
8995 284 tempitem.misc10 = 0;
8996 284 tempitem.wpn = 0;
8997 284 tempitem.wpn2 = 0;
8998 284 tempitem.wpn3 = 0;
8999 284 tempitem.wpn4 = 0;
9000 284 tempitem.wpn5 = 0;
9001 284 tempitem.wpn6 = 0;
9002 284 tempitem.wpn7 = 0;
9003 284 tempitem.wpn8 = 0;
9004 284 tempitem.wpn9 = 0;
9005 284 tempitem.wpn10 = 0;
9006 284 break;
9007 }
9008 case itype_perilring:
9009 {
9010 311 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9011 311 tempitem.misc2 = 0;
9012 311 tempitem.misc3 = 0;
9013 311 tempitem.misc4 = 0;
9014 311 tempitem.misc5 = 0;
9015 311 tempitem.misc6 = 0;
9016 311 tempitem.misc7 = 0;
9017 311 tempitem.misc8 = 0;
9018 311 tempitem.misc9 = 0;
9019 311 tempitem.misc10 = 0;
9020 311 tempitem.wpn = 0;
9021 311 tempitem.wpn2 = 0;
9022 311 tempitem.wpn3 = 0;
9023 311 tempitem.wpn4 = 0;
9024 311 tempitem.wpn5 = 0;
9025 311 tempitem.wpn6 = 0;
9026 311 tempitem.wpn7 = 0;
9027 311 tempitem.wpn8 = 0;
9028 311 tempitem.wpn9 = 0;
9029 311 tempitem.wpn10 = 0;
9030 311 break;
9031 }
9032 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9033 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9034 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9035 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9036 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9037 {
9038 10996 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9039 10996 tempitem.misc1 = 0;
9040 10996 tempitem.misc2 = 0;
9041 10996 tempitem.misc3 = 0;
9042 10996 tempitem.misc4 = 0;
9043 10996 tempitem.misc5 = 0;
9044 10996 tempitem.misc6 = 0;
9045 10996 tempitem.misc7 = 0;
9046 10996 tempitem.misc8 = 0;
9047 10996 tempitem.misc9 = 0;
9048 10996 tempitem.misc10 = 0;
9049 10996 tempitem.wpn = 0;
9050 10996 tempitem.wpn2 = 0;
9051 10996 tempitem.wpn3 = 0;
9052 10996 tempitem.wpn4 = 0;
9053 10996 tempitem.wpn5 = 0;
9054 10996 tempitem.wpn6 = 0;
9055 10996 tempitem.wpn7 = 0;
9056 10996 tempitem.wpn8 = 0;
9057 10996 tempitem.wpn9 = 0;
9058 10996 tempitem.wpn10 = 0;
9059 10996 break;
9060 }
9061 }
9062 73472 }
9063 //Port quest rules to items
9064
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 73472 times.
119296 if( s_version <= 31)
9065 {
9066
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 73172 times.
73472 if(tempitem.family == itype_bomb)
9067 {
9068
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 144 times.
300 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9069 144 else tempitem.flags &= ~ item_flag2;
9070 300 }
9071
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 72886 times.
73172 else if(tempitem.family == itype_sbomb)
9072 {
9073
2/2
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 128 times.
286 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9074 128 else tempitem.flags &= ~ item_flag2;
9075 286 }
9076
9077
2/2
✓ Branch 0 taken 859 times.
✓ Branch 1 taken 72027 times.
72886 else if(tempitem.family == itype_brang)
9078 {
9079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 859 times.
859 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= item_flag4;
9080 859 else tempitem.flags &= ~ item_flag4;
9081 859 }
9082
2/2
✓ Branch 0 taken 71725 times.
✓ Branch 1 taken 302 times.
72027 else if(tempitem.family == itype_wand)
9083 {
9084
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 278 times.
302 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= item_flag3;
9085 278 else tempitem.flags &= ~ item_flag3;
9086 302 }
9087 73472 }
9088
9089 //Port quest rules to items
9090
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 73472 times.
119296 if( s_version <= 37)
9091 {
9092
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 73185 times.
73472 if(tempitem.family == itype_flippers)
9093 {
9094
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 208 times.
287 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= item_flag1;
9095 208 else tempitem.flags &= ~ item_flag1;
9096 287 }
9097
2/2
✓ Branch 0 taken 55497 times.
✓ Branch 1 taken 17688 times.
73185 else if(tempitem.family == itype_sword)
9098 {
9099
2/2
✓ Branch 0 taken 462 times.
✓ Branch 1 taken 17226 times.
17688 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9100 17226 else tempitem.flags &= ~ item_flag5;
9101 17688 }
9102
2/2
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 55195 times.
55497 else if(tempitem.family == itype_wand)
9103 {
9104
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 292 times.
302 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9105 292 else tempitem.flags &= ~ item_flag5;
9106 302 }
9107
4/4
✓ Branch 0 taken 54895 times.
✓ Branch 1 taken 300 times.
✓ Branch 2 taken 610 times.
✓ Branch 3 taken 54285 times.
55195 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9108 {
9109 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9110
2/2
✓ Branch 0 taken 381 times.
✓ Branch 1 taken 529 times.
910 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= item_flag3;
9111 529 else tempitem.flags &= ~ item_flag3;
9112 910 }
9113 73472 }
9114
9115
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 73472 times.
119296 if( s_version < 38)
9116 {
9117
4/4
✓ Branch 0 taken 72613 times.
✓ Branch 1 taken 859 times.
✓ Branch 2 taken 570 times.
✓ Branch 3 taken 72043 times.
73472 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9118 {
9119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1429 times.
1429 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9120 1429 else tempitem.flags &= ~item_flag4;
9121
9122
2/2
✓ Branch 0 taken 703 times.
✓ Branch 1 taken 726 times.
1429 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= item_flag5 | item_flag6;
9123 726 else tempitem.flags &= ~(item_flag5|item_flag6);
9124 1429 }
9125
2/2
✓ Branch 0 taken 71199 times.
✓ Branch 1 taken 844 times.
72043 else if(tempitem.family == itype_arrow)
9126 {
9127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 844 times.
844 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9128 844 else tempitem.flags &= ~item_flag4;
9129
9130
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 432 times.
844 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~item_flag2;
9131 432 else tempitem.flags |= item_flag2;
9132 844 }
9133 73472 }
9134
9135
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 73472 times.
119296 if( s_version < 39)
9136 {
9137
6/6
✓ Branch 0 taken 73188 times.
✓ Branch 1 taken 284 times.
✓ Branch 2 taken 72888 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 610 times.
✓ Branch 5 taken 72278 times.
73472 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9138 {
9139
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1178 times.
1194 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= item_flag5;
9140 1178 else tempitem.flags &= ~item_flag5;
9141 1194 }
9142
2/2
✓ Branch 0 taken 623 times.
✓ Branch 1 taken 71655 times.
72278 else if(tempitem.family == itype_potion)
9143 {
9144
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 461 times.
623 if(get_qr(qr_NONBUBBLEMEDICINE))
9145 {
9146 162 tempitem.flags &= ~(item_flag3|item_flag4);
9147 162 }
9148 else
9149 {
9150 461 tempitem.flags |= item_flag3;
9151
2/2
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 331 times.
461 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9152 331 else tempitem.flags &= ~item_flag4;
9153 }
9154 623 }
9155
2/2
✓ Branch 0 taken 71087 times.
✓ Branch 1 taken 568 times.
71655 else if(tempitem.family == itype_triforcepiece)
9156 {
9157
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 484 times.
568 if(get_qr(qr_NONBUBBLETRIFORCE))
9158 {
9159 84 tempitem.flags |= item_flag3;
9160
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 28 times.
84 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9161 28 else tempitem.flags &= ~item_flag4;
9162 84 }
9163 else
9164 {
9165 484 tempitem.flags &= ~(item_flag3|item_flag4);
9166 }
9167 568 }
9168 73472 }
9169
9170
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 73472 times.
119296 if( s_version < 40)
9171 {
9172
4/4
✓ Branch 0 taken 72540 times.
✓ Branch 1 taken 932 times.
✓ Branch 2 taken 311 times.
✓ Branch 3 taken 72229 times.
73472 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9173 {
9174
2/2
✓ Branch 0 taken 313 times.
✓ Branch 1 taken 930 times.
1243 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= item_flag1;
9175 930 else tempitem.flags &= ~item_flag1;
9176 1243 }
9177
8/8
✓ Branch 0 taken 71619 times.
✓ Branch 1 taken 610 times.
✓ Branch 2 taken 53931 times.
✓ Branch 3 taken 17688 times.
✓ Branch 4 taken 53629 times.
✓ Branch 5 taken 302 times.
✓ Branch 6 taken 284 times.
✓ Branch 7 taken 53345 times.
72229 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9178 {
9179
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 18776 times.
18884 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= item_flag8;
9180 18776 else tempitem.flags &= ~item_flag8;
9181 18884 }
9182
6/6
✓ Branch 0 taken 55784 times.
✓ Branch 1 taken 17688 times.
✓ Branch 2 taken 55482 times.
✓ Branch 3 taken 302 times.
✓ Branch 4 taken 287 times.
✓ Branch 5 taken 55195 times.
73472 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9183 {
9184
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 18173 times.
18277 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= item_flag7;
9185 18173 else tempitem.flags &= ~item_flag7;
9186 18277 }
9187
2/2
✓ Branch 0 taken 54911 times.
✓ Branch 1 taken 284 times.
55195 else if(tempitem.family == itype_cbyrna)
9188 {
9189 284 tempitem.flags |= item_flag7;
9190 284 }
9191 73472 }
9192
9193
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 73472 times.
119296 if( s_version < 41 )
9194 {
9195
2/2
✓ Branch 0 taken 55784 times.
✓ Branch 1 taken 17688 times.
73472 if(tempitem.family == itype_sword)
9196 {
9197
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 17404 times.
17688 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= item_flag9;
9198 17404 else tempitem.flags &= ~item_flag9;
9199
9200
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 17260 times.
17688 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= item_flag10;
9201 17260 else tempitem.flags &= ~item_flag10;
9202 17688 }
9203 73472 }
9204
9205
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 73472 times.
119296 if( s_version < 42 )
9206 {
9207
2/2
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 73170 times.
73472 if(tempitem.family == itype_wand)
9208 {
9209
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 278 times.
302 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= item_flag3;
9210 278 else tempitem.flags &= ~item_flag3;
9211
9212 302 tempitem.flags &= ~item_flag6;
9213 302 }
9214
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 72883 times.
73170 else if(tempitem.family == itype_hammer)
9215 {
9216 287 tempitem.flags &= ~item_flag3;
9217 287 }
9218
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 72599 times.
72883 else if(tempitem.family == itype_cbyrna)
9219 {
9220 284 tempitem.flags |= item_flag3;
9221
9222 284 tempitem.flags &= ~item_flag6;
9223 284 }
9224
2/2
✓ Branch 0 taken 54911 times.
✓ Branch 1 taken 17688 times.
72599 else if(tempitem.family == itype_sword)
9225 {
9226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17688 times.
17688 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= item_flag6;
9227 17688 else tempitem.flags &= ~item_flag6;
9228 17688 }
9229 73472 }
9230
9231
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 73472 times.
119296 if( s_version < 43 )
9232 {
9233
2/2
✓ Branch 0 taken 73140 times.
✓ Branch 1 taken 332 times.
73472 if(tempitem.family == itype_whistle)
9234 {
9235
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 320 times.
332 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= item_flag3;
9236 320 else tempitem.flags &= ~item_flag3;
9237 332 }
9238 73472 }
9239
9240
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 73472 times.
119296 if( s_version < 45 )
9241 {
9242
2/2
✓ Branch 0 taken 73185 times.
✓ Branch 1 taken 287 times.
73472 if(tempitem.family == itype_flippers)
9243 {
9244 287 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9245 287 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9246 287 }
9247 73472 }
9248
9249
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 73472 times.
119296 if( s_version < 46 )
9250 {
9251
2/2
✓ Branch 0 taken 73188 times.
✓ Branch 1 taken 284 times.
73472 if(tempitem.family == itype_raft)
9252 {
9253 284 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9254 284 }
9255 73472 }
9256
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 73472 times.
119296 if ( s_version < 34 ) //! set the default counter for older quests.
9257 {
9258
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 73357 times.
73472 if ( (tempitem.flags & item_rupee_magic) )
9259 {
9260 115 tempitem.cost_counter[0] = 1;
9261 115 }
9262 else
9263 {
9264
2/2
✓ Branch 0 taken 44032 times.
✓ Branch 1 taken 29325 times.
73357 if(get_qr(qr_ENABLEMAGIC))
9265 44032 tempitem.cost_counter[0] = 4;
9266 else
9267 {
9268 29325 tempitem.cost_amount[0] = 0;
9269 29325 tempitem.cost_counter[0] = -1;
9270 }
9271 }
9272 73472 }
9273
9274
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 73472 times.
119296 if ( s_version < 35 ) //new Lens of Truth flags
9275 {
9276
2/2
✓ Branch 0 taken 73212 times.
✓ Branch 1 taken 260 times.
73472 if ( tempitem.family == itype_lens )
9277 {
9278
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 12 times.
260 if ( get_qr(qr_RAFTLENS) )
9279 {
9280 12 tempitem.flags |= item_flag4;
9281 12 }
9282
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 167 times.
260 if ( get_qr(qr_LENSHINTS) )
9283 {
9284 167 tempitem.flags |= item_flag1;
9285 167 }
9286
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 16 times.
260 if ( get_qr(qr_LENSSEESENEMIES) )
9287 {
9288 16 tempitem.flags |= item_flag5;
9289 16 }
9290 260 }
9291 73472 }
9292
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 73472 times.
119296 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9293 {
9294
2/2
✓ Branch 0 taken 587776 times.
✓ Branch 1 taken 73472 times.
661248 for ( int32_t q = 0; q < 8; q++ )
9295 {
9296 587776 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9297 587776 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9298 587776 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9299 587776 tempitem.sprite_initiald[q] = 0;
9300 587776 }
9301 73472 tempitem.sprite_script = 0;
9302 73472 }
9303
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 73472 times.
119296 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9304 {
9305 73472 tempitem.pickupflag = 0;
9306 73472 }
9307
9308
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 73472 times.
119296 if( s_version < 51 )
9309 {
9310
2/2
✓ Branch 0 taken 72862 times.
✓ Branch 1 taken 610 times.
73472 if( tempitem.family == itype_candle )
9311 {
9312 610 tempitem.misc4 = 50; //Step speed
9313 610 }
9314 73472 }
9315
9316
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 73472 times.
119296 if( s_version < 52 )
9317 {
9318
2/2
✓ Branch 0 taken 72599 times.
✓ Branch 1 taken 873 times.
73472 if( tempitem.family == itype_shield )
9319 873 tempitem.flags |= item_flag1; //'Block Front' flag
9320 73472 }
9321
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 73472 times.
119296 if(s_version < 53)
9322 {
9323
4/4
✓ Branch 0 taken 72042 times.
✓ Branch 1 taken 844 times.
✓ Branch 2 taken 300 times.
✓ Branch 3 taken 286 times.
73472 switch(tempitem.family)
9324 {
9325 case itype_arrow:
9326 844 tempitem.cost_counter[1] = crARROWS;
9327 844 tempitem.cost_amount[1] = 1;
9328 844 break;
9329 case itype_bomb:
9330 300 tempitem.cost_counter[1] = crBOMBS;
9331 300 tempitem.cost_amount[1] = 1;
9332 300 break;
9333 case itype_sbomb:
9334 286 tempitem.cost_counter[1] = crSBOMBS;
9335 286 tempitem.cost_amount[1] = 1;
9336 286 break;
9337 default:
9338 72042 tempitem.cost_counter[1] = crNONE;
9339 72042 tempitem.cost_amount[1] = 0;
9340 72042 }
9341 73472 tempitem.magiccosttimer[1] = 0;
9342 73472 }
9343
2/2
✓ Branch 0 taken 43008 times.
✓ Branch 1 taken 76288 times.
119296 if( s_version < 54 )
9344 {
9345
2/2
✓ Branch 0 taken 75988 times.
✓ Branch 1 taken 300 times.
76288 if( tempitem.family == itype_flippers )
9346 300 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9347 76288 }
9348
2/2
✓ Branch 0 taken 43008 times.
✓ Branch 1 taken 76288 times.
119296 if(s_version < 55)
9349 {
9350
3/3
✓ Branch 0 taken 590 times.
✓ Branch 1 taken 590 times.
✓ Branch 2 taken 75108 times.
76288 switch(tempitem.family)
9351 {
9352 case itype_spinscroll:
9353 case itype_quakescroll:
9354 590 tempitem.usesound2 = WAV_ZN1CHARGE;
9355 590 break;
9356 case itype_spinscroll2:
9357 case itype_quakescroll2:
9358 590 tempitem.usesound2 = WAV_ZN1CHARGE2;
9359 590 break;
9360 }
9361 76288 }
9362
2/2
✓ Branch 0 taken 43008 times.
✓ Branch 1 taken 76288 times.
119296 if(s_version < 56)
9363 {
9364
4/4
✓ Branch 0 taken 75046 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 636 times.
✓ Branch 3 taken 311 times.
76288 switch(tempitem.family)
9365 {
9366 case itype_divinefire:
9367
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 11 times.
295 SETFLAG(tempitem.flags, item_flag9, version < 0x255); //Strong Fire
9368
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 213 times.
295 SETFLAG(tempitem.flags, item_flag10, version < 0x250); //Magic Fire
9369 295 tempitem.flags |= item_flag11; //Divine Fire
9370 295 break;
9371 case itype_candle:
9372
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 319 times.
636 SETFLAG(tempitem.flags, item_flag9, tempitem.fam_type > 1); //Strong Fire
9373 636 tempitem.flags &= ~item_flag10; //Magic Fire
9374 636 tempitem.flags &= ~item_flag11; //Divine Fire
9375 636 break;
9376 case itype_book:
9377 311 tempitem.flags |= item_flag9; //Strong Fire
9378 311 tempitem.flags |= item_flag10; //Magic Fire
9379 311 tempitem.flags &= ~item_flag11; //Divine Fire
9380 311 break;
9381 }
9382 76288 }
9383
9384
2/2
✓ Branch 0 taken 108308 times.
✓ Branch 1 taken 10988 times.
119296 if(tempitem.fam_type==0) // Always do this
9385 10988 tempitem.fam_type=1;
9386
9387 119296 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9388 119296 }
9389
9390 466 return 0;
9391 467 }
9392
9393 static bool did_init_def_items = false;
9394 238458 void init_def_items()
9395 {
9396
2/2
✓ Branch 0 taken 238098 times.
✓ Branch 1 taken 360 times.
238458 if(did_init_def_items) return;
9397 360 did_init_def_items = true;
9398 360 default_items[3].cost_counter[1] = crBOMBS;
9399 360 default_items[13].cost_counter[1] = crARROWS;
9400 360 default_items[14].cost_counter[1] = crARROWS;
9401 360 default_items[48].cost_counter[1] = crSBOMBS;
9402 360 default_items[57].cost_counter[1] = crARROWS;
9403 238458 }
9404 238458 void reset_itembuf(itemdata *item, int32_t id)
9405 {
9406 238458 init_def_items();
9407
2/2
✓ Branch 0 taken 100005 times.
✓ Branch 1 taken 138453 times.
238458 if(id<iLast)
9408 {
9409 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9410 138453 word tile = item->tile;
9411 138453 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9412 138453 int32_t ltm = item->ltm;
9413
9414 138453 memcpy(item,&default_items[id],sizeof(itemdata));
9415 138453 item->tile = tile;
9416 138453 item->misc_flags = miscs;
9417 138453 item->csets = cset;
9418 138453 item->frames = frames;
9419 138453 item->speed = speed;
9420 138453 item->delay = delay;
9421 138453 item->ltm = ltm;
9422 138453 }
9423 238458 }
9424
9425 99328 void reset_itemname(int32_t id)
9426 {
9427 99328 sprintf(item_string[id],"zz%03d",id);
9428
9429
2/2
✓ Branch 0 taken 43844 times.
✓ Branch 1 taken 55484 times.
99328 if(id < iLast)
9430 55484 strcpy(item_string[id],old_item_string[id]);
9431 99328 }
9432
9433 467 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9434 {
9435
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 24 times.
467 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_weapons);
9436
9437 467 word weapons_to_read=MAXWPNS;
9438 int32_t dummy;
9439 byte padding;
9440 wpndata tempweapon;
9441 467 word s_version=0;
9442
9443
9444
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 6 times.
467 if(Header->zelda_version < 0x186)
9445 {
9446 6 weapons_to_read=64;
9447 6 }
9448
9449
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 6 times.
467 if(Header->zelda_version < 0x185)
9450 {
9451 6 weapons_to_read=32;
9452 6 }
9453
9454
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 443 times.
467 if(Header->zelda_version > 0x192)
9455 {
9456 443 weapons_to_read=0;
9457
9458 //section version info
9459
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetw(&s_version,f))
9460 {
9461 return qe_invalid;
9462 }
9463
9464 443 FFCore.quest_format[vWeaponSprites] = s_version;
9465
9466
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!read_deprecated_section_cversion(f))
9467 {
9468 return qe_invalid;
9469 }
9470
9471 //section size
9472
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetl(&dummy,f))
9473 {
9474 return qe_invalid;
9475 }
9476
9477 //finally... section data
9478
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetw(&weapons_to_read,f))
9479 {
9480 return qe_invalid;
9481 }
9482
9483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if (weapons_to_read > MAXWPNS)
9484 {
9485 return qe_invalid;
9486 }
9487 443 }
9488
9489
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 83 times.
467 if(s_version>2)
9490 {
9491
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 384 times.
98688 for(int32_t i=0; i<weapons_to_read; i++)
9492 {
9493 char tempname[64];
9494
9495
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!pfread(tempname, 64, f))
9496 {
9497 return qe_invalid;
9498 }
9499
9500 98304 weapon_string[i][0] = '\0';
9501 98304 strncat(weapon_string[i], tempname, 64 - 1);
9502 98304 }
9503
9504
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(s_version<4)
9505 {
9506 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9507 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9508 }
9509
9510
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(s_version<5)
9511 {
9512 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9513 }
9514
9515 /*
9516 if (s_version<6)
9517 {
9518 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9519 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9520 }
9521 */
9522 384 }
9523
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
9524 {
9525
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXWPNS; i++)
9526 20992 reset_weaponname(i);
9527 82 }
9528
9529
2/2
✓ Branch 0 taken 107116 times.
✓ Branch 1 taken 467 times.
107583 for(int32_t i=0; i<weapons_to_read; i++)
9530 {
9531 107116 word oldtile = 0;
9532
2/2
✓ Branch 0 taken 44544 times.
✓ Branch 1 taken 62572 times.
107116 if (s_version < 8)
9533 {
9534
1/2
✓ Branch 0 taken 62572 times.
✗ Branch 1 not taken.
62572 if (!p_igetw(&oldtile, f))
9535 return qe_invalid;
9536 62572 }
9537
9538
1/2
✓ Branch 0 taken 107116 times.
✗ Branch 1 not taken.
107116 if(!p_getc(&tempweapon.misc,f))
9539 {
9540 return qe_invalid;
9541 }
9542
9543
1/2
✓ Branch 0 taken 107116 times.
✗ Branch 1 not taken.
107116 if(!p_getc(&tempweapon.csets,f))
9544 {
9545 return qe_invalid;
9546 }
9547
9548
1/2
✓ Branch 0 taken 107116 times.
✗ Branch 1 not taken.
107116 if(!p_getc(&tempweapon.frames,f))
9549 {
9550 return qe_invalid;
9551 }
9552
9553
1/2
✓ Branch 0 taken 107116 times.
✗ Branch 1 not taken.
107116 if(!p_getc(&tempweapon.speed,f))
9554 {
9555 return qe_invalid;
9556 }
9557
9558
1/2
✓ Branch 0 taken 107116 times.
✗ Branch 1 not taken.
107116 if(!p_getc(&tempweapon.type,f))
9559 {
9560 return qe_invalid;
9561 }
9562
9563
2/2
✓ Branch 0 taken 61292 times.
✓ Branch 1 taken 45824 times.
107116 if ( s_version >= 7 )
9564 {
9565
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_igetw(&tempweapon.script,f))
9566 {
9567 return qe_invalid;
9568 }
9569
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if(!p_igetl(&tempweapon.tile,f))
9570 {
9571 return qe_invalid;
9572 }
9573 45824 }
9574
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 61292 times.
107116 if ( s_version < 7 )
9575 {
9576 61292 tempweapon.tile = oldtile;
9577 61292 }
9578
9579
2/2
✓ Branch 0 taken 102316 times.
✓ Branch 1 taken 4800 times.
107116 if(Header->zelda_version < 0x193)
9580 {
9581
1/2
✓ Branch 0 taken 4800 times.
✗ Branch 1 not taken.
4800 if(!p_getc(&padding,f))
9582 {
9583 return qe_invalid;
9584 }
9585 4800 }
9586
9587
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 8812 times.
107116 if(s_version < 6)
9588 {
9589
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 8794 times.
8812 if(i==ewFIRETRAIL)
9590 {
9591 18 tempweapon.misc |= WF_BEHIND;
9592 18 }
9593 else
9594 8794 tempweapon.misc &= ~WF_BEHIND;
9595 8812 }
9596
9597
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 106860 times.
107116 if (!should_skip)
9598 106860 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9599 107116 }
9600
9601
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 466 times.
467 if (should_skip)
9602 1 return 0;
9603
9604
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version<2)
9605 {
9606 82 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9607 82 }
9608
9609
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version<5)
9610 {
9611 82 wpnsbuf[iwQuarterHearts].tile=1;
9612 82 wpnsbuf[iwQuarterHearts].csets=1;
9613 82 }
9614
9615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 466 times.
466 if(Header->zelda_version < 0x176)
9616 {
9617 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9618 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9619 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9620 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9621 }
9622
9623
3/4
✓ Branch 0 taken 448 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
471 if((Header->zelda_version < 0x192)||
9624
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 443 times.
448 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9625 {
9626 18 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9627 18 }
9628
9629
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 443 times.
466 if((Header->zelda_version < 0x210))
9630 {
9631 23 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9632 23 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9633 23 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9634 23 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9635 23 }
9636
9637 466 return 0;
9638 467 }
9639
9640 221148 static void guy_update_firesfx(guydata& tempguy)
9641 {
9642 221148 tempguy.firesfx = 0;
9643
2/2
✓ Branch 0 taken 6343 times.
✓ Branch 1 taken 214805 times.
221148 if (tempguy.family == eeWIZZ)
9644 {
9645
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 962 times.
✓ Branch 2 taken 3876 times.
✓ Branch 3 taken 816 times.
✓ Branch 4 taken 689 times.
6343 switch (tempguy.attributes[1])
9646 {
9647 case 0: // normal weapon
9648 3876 tempguy.firesfx = WAV_WAND;
9649 3876 break;
9650 case 1: // 8 shots
9651
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 734 times.
816 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) tempguy.firesfx = WAV_FIRE;
9652 else
9653 {
9654
3/8
✓ Branch 0 taken 631 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
734 switch (tempguy.weapon)
9655 {
9656 case ewFireTrail:
9657 case ewFlame:
9658 case ewFlame2Trail:
9659 case ewFlame2:
9660 631 tempguy.firesfx = WAV_FIRE;
9661 631 break;
9662 case ewWind:
9663 case ewMagic:
9664 87 tempguy.firesfx = WAV_WAND;
9665 87 break;
9666 case ewIce:
9667 tempguy.firesfx = WAV_ZN1ICE;
9668 break;
9669 case ewRock:
9670 tempguy.firesfx = WAV_ZN1ROCK;
9671 break;
9672 case ewFireball2:
9673 case ewFireball:
9674 16 tempguy.firesfx = WAV_ZN1FIREBALL;
9675 16 break;
9676 case ewBrang:
9677 tempguy.firesfx = WAV_BRANG;
9678 break;
9679 case ewBomb:case ewSBomb: case ewLitBomb:case ewLitSBomb:
9680 tempguy.firesfx = WAV_BOMB;
9681 break;
9682 default:
9683 tempguy.firesfx = 0;
9684 break;
9685 }
9686 734 break;
9687 }
9688 case 2: // Summon
9689 1044 tempguy.firesfx = WAV_FIRE;
9690 1044 break;
9691 case 3: // Summon Layer
9692 689 tempguy.firesfx = get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE;
9693 689 break;
9694 }
9695 6343 }
9696 else
9697 {
9698
6/6
✓ Branch 0 taken 162803 times.
✓ Branch 1 taken 52002 times.
✓ Branch 2 taken 41332 times.
✓ Branch 3 taken 204135 times.
✓ Branch 4 taken 46669 times.
✓ Branch 5 taken 46665 times.
214805 if ((tempguy.family == eeWALK || tempguy.family == eePROJECTILE) && (tempguy.attributes[0] == e1tSUMMON || tempguy.attributes[0] == e1tSUMMONLAYER))
9699 {
9700 93334 tempguy.firesfx = get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE;
9701 93334 }
9702 else
9703 {
9704
7/8
✓ Branch 0 taken 9476 times.
✓ Branch 1 taken 2324 times.
✓ Branch 2 taken 1784 times.
✓ Branch 3 taken 12650 times.
✓ Branch 4 taken 171760 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3906 times.
✓ Branch 7 taken 2235 times.
204135 switch (tempguy.weapon)
9705 {
9706 case ewFireTrail:
9707 case ewFlame:
9708 case ewFlame2Trail:
9709 case ewFlame2:
9710 9476 tempguy.firesfx = WAV_FIRE;
9711 9476 break;
9712 case ewWind:
9713 case ewMagic:
9714 1784 tempguy.firesfx = WAV_WAND;
9715 1784 break;
9716 case ewIce:
9717 tempguy.firesfx = WAV_ZN1ICE;
9718 break;
9719 case ewRock:
9720 3906 tempguy.firesfx = WAV_ZN1ROCK;
9721 3906 break;
9722 case ewFireball2:
9723 case ewFireball:
9724 12650 tempguy.firesfx = WAV_ZN1FIREBALL;
9725 12650 break;
9726 case ewBrang:
9727 2235 tempguy.firesfx = WAV_BRANG;
9728 2235 break;
9729 case ewBomb:case ewSBomb: case ewLitBomb:case ewLitSBomb:
9730 2324 tempguy.firesfx = WAV_BOMB;
9731 2324 break;
9732 default:
9733 171760 tempguy.firesfx = 0;
9734 171760 break;
9735 }
9736 }
9737 }
9738 210482 }
9739
9740 210482 static void guy_update_weaponflags(guydata& tempguy)
9741 {
9742 210482 tempguy.wunblockable = 0;
9743 210482 tempguy.wmoveflags = move_none;
9744
4/4
✓ Branch 0 taken 204053 times.
✓ Branch 1 taken 6429 times.
✓ Branch 2 taken 2958 times.
✓ Branch 3 taken 201095 times.
210482 if (tempguy.weapon == ewFlame || tempguy.weapon == ewFireTrail)
9745 9387 tempguy.wmoveflags |= (move_obeys_grav | move_can_pitfall);
9746 210482 tempguy.weapoverrideFLAGS = 0;
9747 210482 tempguy.weap_hxofs = 0;
9748 210482 tempguy.weap_hyofs = 0;
9749 210482 tempguy.weap_hxsz = 0;
9750 210482 tempguy.weap_hysz = 0;
9751 210482 tempguy.weap_hzsz = 0;
9752 210482 tempguy.weap_xofs = 0;
9753 210482 tempguy.weap_yofs = 0;
9754 210482 tempguy.weap_tilew = 0;
9755 210482 tempguy.weap_tileh = 0;
9756
5/5
✓ Branch 0 taken 2474 times.
✓ Branch 1 taken 169804 times.
✓ Branch 2 taken 18264 times.
✓ Branch 3 taken 12666 times.
✓ Branch 4 taken 7274 times.
210482 switch (tempguy.weapon)
9757 {
9758 case ewFireball: case ewFireball2:
9759 12666 tempguy.wstep = 175;
9760 12666 break;
9761 case ewSword: case ewLitBomb: case ewLitSBomb:
9762 case ewRock: case ewMagic: case ewWind:
9763 18264 tempguy.wstep = 300;
9764 18264 break;
9765 case ewArrow:
9766 2474 tempguy.wstep = 200;
9767 2474 break;
9768 case ewFlame: case ewFlame2:
9769 7274 tempguy.wstep = 100;
9770 7274 break;
9771 default:
9772 169804 tempguy.wstep = 0;
9773 169804 break;
9774 }
9775
2/2
✓ Branch 0 taken 1052410 times.
✓ Branch 1 taken 210482 times.
1262892 for (int q = 0; q < WPNSPR_MAX; ++q)
9776 {
9777 1052410 tempguy.burnsprs[q] = 0;
9778 1052410 tempguy.light_rads[q] = 0;
9779 1052410 }
9780 210482 }
9781
9782 210482 static void guy_update_weaponspecialsfx(guydata& tempguy)
9783 {
9784
3/3
✓ Branch 0 taken 2235 times.
✓ Branch 1 taken 205868 times.
✓ Branch 2 taken 2379 times.
210482 switch (tempguy.weapon)
9785 {
9786 case ewBrang:
9787 2235 tempguy.specialsfx = WAV_BRANG;
9788 2235 break;
9789 case ewBomb: case ewSBomb: case ewLitBomb:case ewLitSBomb:
9790 2379 tempguy.specialsfx = WAV_BOMB;
9791 2379 break;
9792 default:
9793 205868 tempguy.specialsfx = 0;
9794 205868 break;
9795 }
9796 210482 }
9797
9798 466 void init_guys(int32_t guyversion)
9799 {
9800
2/2
✓ Branch 0 taken 238592 times.
✓ Branch 1 taken 466 times.
239058 for(int32_t i=0; i<MAXGUYS; i++)
9801 {
9802 238592 guysbuf[i] = default_guys[0];
9803 238592 }
9804
9805
2/2
✓ Branch 0 taken 82482 times.
✓ Branch 1 taken 466 times.
82948 for(int32_t i=0; i<OLDMAXGUYS; i++)
9806 {
9807 82482 guysbuf[i] = default_guys[i];
9808
2/2
✓ Branch 0 taken 81550 times.
✓ Branch 1 taken 932 times.
82482 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].attributes[9] == 1) ? iwLargeShadow : iwShadow;
9809 82482 guysbuf[i].spr_death = iwDeath;
9810 82482 guysbuf[i].spr_spawn = iwSpawn;
9811 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9812
4/4
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 67968 times.
✓ Branch 2 taken 14432 times.
✓ Branch 3 taken 82 times.
82482 if(guyversion<=3 && i==ePATRABS)
9813 {
9814 82 guysbuf[i].bosspal=spDIG;
9815 82 guysbuf[i].cset=14;
9816 82 guysbuf[i].attributes[8] = 14;
9817 82 }
9818
9819
2/2
✓ Branch 0 taken 67968 times.
✓ Branch 1 taken 14514 times.
82482 if(guyversion<=3)
9820 {
9821 // Rope/Ghini Flash rules
9822
2/2
✓ Branch 0 taken 4071 times.
✓ Branch 1 taken 10443 times.
14514 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9823 {
9824
2/2
✓ Branch 0 taken 10384 times.
✓ Branch 1 taken 59 times.
10443 if(i==eROPE2)
9825 {
9826 59 guysbuf[i].flags &= ~guy_flashing;
9827 59 }
9828 10443 }
9829
9830
2/2
✓ Branch 0 taken 12390 times.
✓ Branch 1 taken 2124 times.
14514 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9831 {
9832
12/12
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 2100 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 2088 times.
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 2076 times.
✓ Branch 7 taken 12 times.
✓ Branch 8 taken 2064 times.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 2052 times.
2124 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9833 {
9834 72 guysbuf[i].flags &= ~guy_flashing;
9835 72 }
9836 2124 }
9837
9838
2/2
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
14514 if(i==eGHINI2)
9839 {
9840
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 4 times.
82 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9841 {
9842 4 guysbuf[i].flags |= guy_blinking;
9843 4 }
9844
9845
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 38 times.
82 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9846 {
9847 38 guysbuf[i].flags |= guy_transparent;
9848 38 }
9849 82 }
9850
9851
4/4
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 14350 times.
14514 if (i == eDIG1 || i == eDIG3)
9852 {
9853 164 guysbuf[i].flags |= guy_ignore_kill_all;
9854 164 }
9855 14514 }
9856
9857 // Darknut fix
9858
10/10
✓ Branch 0 taken 82016 times.
✓ Branch 1 taken 466 times.
✓ Branch 2 taken 81550 times.
✓ Branch 3 taken 466 times.
✓ Branch 4 taken 81084 times.
✓ Branch 5 taken 466 times.
✓ Branch 6 taken 80618 times.
✓ Branch 7 taken 466 times.
✓ Branch 8 taken 466 times.
✓ Branch 9 taken 80152 times.
82482 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9859 {
9860
2/2
✓ Branch 0 taken 1925 times.
✓ Branch 1 taken 405 times.
2330 if(get_qr(qr_NEWENEMYTILES))
9861 {
9862 1925 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9863 1925 guysbuf[i].s_width=guysbuf[i].e_width;
9864 1925 guysbuf[i].s_height=guysbuf[i].e_height;
9865 1925 }
9866 405 else guysbuf[i].s_tile=860;
9867
9868
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 2010 times.
2330 if(!get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9869 2010 guysbuf[i].flags &= ~guy_bkshield;
9870 else
9871 320 guysbuf[i].flags |= guy_bkshield;
9872 2330 }
9873
9874
4/4
✓ Branch 0 taken 82016 times.
✓ Branch 1 taken 466 times.
✓ Branch 2 taken 82432 times.
✓ Branch 3 taken 50 times.
82482 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9875 {
9876 50 guysbuf[i].attributes[2] = (i == eFGELTRIB ? eFZOL : eZOL);
9877 50 }
9878
9879 82482 guy_update_firesfx(guysbuf[i]);
9880 82482 guy_update_weaponflags(guysbuf[i]);
9881 82482 guy_update_weaponspecialsfx(guysbuf[i]);
9882 82482 }
9883 466 }
9884
9885 20992 void reset_weaponname(int32_t i)
9886 {
9887
2/2
✓ Branch 0 taken 7216 times.
✓ Branch 1 taken 13776 times.
20992 if(i<wLast)
9888 {
9889 7216 strcpy(weapon_string[i],old_weapon_string[i]);
9890 7216 }
9891 else
9892 13776 sprintf(weapon_string[i],"zz%03d",i);
9893 20992 }
9894
9895 466 void init_item_drop_sets()
9896 {
9897
2/2
✓ Branch 0 taken 119296 times.
✓ Branch 1 taken 466 times.
119762 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9898 {
9899 // item_drop_sets[i] = default_item_drop_sets[0];
9900 119296 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9901 119296 }
9902
9903
2/2
✓ Branch 0 taken 6058 times.
✓ Branch 1 taken 466 times.
6524 for(int32_t i=0; i<isMAX; i++)
9904 {
9905 6058 item_drop_sets[i] = default_item_drop_sets[i];
9906
9907 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9908
2/2
✓ Branch 0 taken 60580 times.
✓ Branch 1 taken 6058 times.
66638 for(int32_t j=0; j<10; ++j)
9909 {
9910 60580 int32_t it = item_drop_sets[i].item[j];
9911
9912
3/4
✓ Branch 0 taken 42596 times.
✓ Branch 1 taken 17984 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2748 times.
60580 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9913
2/2
✓ Branch 0 taken 2748 times.
✓ Branch 1 taken 39848 times.
42596 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9914 {
9915 2748 item_drop_sets[i].chance[j+1]=0;
9916 2748 }
9917
4/4
✓ Branch 0 taken 1864 times.
✓ Branch 1 taken 55968 times.
✓ Branch 2 taken 144 times.
✓ Branch 3 taken 1720 times.
57832 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9918 {
9919 144 item_drop_sets[i].chance[j+1]=0;
9920 144 }
9921
9922 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9923
2/2
✓ Branch 0 taken 60556 times.
✓ Branch 1 taken 24 times.
60580 if(itemsbuf[it].family == itype_misc)
9924 {
9925 // If a non-gameplay item was selected, then item drop was aborted.
9926 // Reflect this by increasing the 'Nothing' chance accordingly.
9927 24 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9928 24 item_drop_sets[i].chance[j+1]=0;
9929 24 }
9930 60580 }
9931 6058 }
9932 466 }
9933
9934 466 void init_favorites()
9935 {
9936
2/2
✓ Branch 0 taken 587160 times.
✓ Branch 1 taken 466 times.
587626 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9937 {
9938 587160 favorite_combos[i]=-1;
9939 587160 }
9940 466 }
9941
9942 const char *ctype_name[cMAX]=
9943 {
9944 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9945 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9946 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9947 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9948 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9949 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9950 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9951 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9952 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9953 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9954 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9955 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9956 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9957 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9958 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9959 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9960 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9961 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9962 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9963 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9964 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9965 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9966 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9967 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9968 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9969 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9970 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9971 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9972
9973 };
9974
9975 758 int32_t init_combo_classes()
9976 {
9977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 758 times.
758 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9978
2/2
✓ Branch 0 taken 138714 times.
✓ Branch 1 taken 758 times.
139472 for(int32_t i=0; i<cMAX; i++)
9979 {
9980 138714 combo_class_buf[i] = default_combo_classes[i];
9981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138714 times.
138714 if ( char const* nm = zi->getComboTypeName(i) )
9982 {
9983 138714 size_t len = strlen(nm);
9984
2/2
✓ Branch 0 taken 8877696 times.
✓ Branch 1 taken 138714 times.
9016410 for ( size_t q = 0; q < 64; q++ )
9985 {
9986
2/2
✓ Branch 0 taken 2032198 times.
✓ Branch 1 taken 6845498 times.
8877696 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9987 8877696 }
9988 138714 }
9989 138714 }
9990
9991 758 return 0;
9992 }
9993
9994 310 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites)
9995 {
9996
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 264 times.
310 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_herosprites);
9997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 310 times.
310 if (should_skip) return 0;
9998
9999
1/2
✓ Branch 0 taken 310 times.
✗ Branch 1 not taken.
310 assert(v_herosprites < 6);
10000
10001 310 zinit.hero_swim_speed=67; //default
10002 310 setupherotiles(zinit.heroAnimationStyle);
10003 310 setupherodefenses();
10004 310 setupherooffsets();
10005
10006
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 205 times.
310 if(v_herosprites>=0)
10007 {
10008 word tile, tile2;
10009 byte flip, extend, dummy_byte;
10010
10011
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10012 {
10013
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10014 {
10015 return qe_invalid;
10016 }
10017
10018
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10019 {
10020 return qe_invalid;
10021 }
10022
10023
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10024 {
10025 return qe_invalid;
10026 }
10027
10028 820 walkspr[i][spr_tile]=(int32_t)tile;
10029 820 walkspr[i][spr_flip]=(int32_t)flip;
10030 820 walkspr[i][spr_extend]=(int32_t)extend;
10031 820 }
10032
10033
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10034 {
10035
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10036 {
10037 return qe_invalid;
10038 }
10039
10040
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10041 {
10042 return qe_invalid;
10043 }
10044
10045
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10046 {
10047 return qe_invalid;
10048 }
10049
10050 820 stabspr[i][spr_tile]=(int32_t)tile;
10051 820 stabspr[i][spr_flip]=(int32_t)flip;
10052 820 stabspr[i][spr_extend]=(int32_t)extend;
10053 820 }
10054
10055
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10056 {
10057
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10058 {
10059 return qe_invalid;
10060 }
10061
10062
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10063 {
10064 return qe_invalid;
10065 }
10066
10067
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10068 {
10069 return qe_invalid;
10070 }
10071
10072 820 slashspr[i][spr_tile]=(int32_t)tile;
10073 820 slashspr[i][spr_flip]=(int32_t)flip;
10074 820 slashspr[i][spr_extend]=(int32_t)extend;
10075 820 }
10076
10077
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10078 {
10079
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10080 {
10081 return qe_invalid;
10082 }
10083
10084
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10085 {
10086 return qe_invalid;
10087 }
10088
10089
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10090 {
10091 return qe_invalid;
10092 }
10093
10094 820 floatspr[i][spr_tile]=(int32_t)tile;
10095 820 floatspr[i][spr_flip]=(int32_t)flip;
10096 820 floatspr[i][spr_extend]=(int32_t)extend;
10097 820 }
10098
10099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(v_herosprites>1)
10100 {
10101
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10102 {
10103
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10104 {
10105 return qe_invalid;
10106 }
10107
10108
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10109 {
10110 return qe_invalid;
10111 }
10112
10113
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10114 {
10115 return qe_invalid;
10116 }
10117
10118 820 swimspr[i][spr_tile]=(int32_t)tile;
10119 820 swimspr[i][spr_flip]=(int32_t)flip;
10120 820 swimspr[i][spr_extend]=(int32_t)extend;
10121 820 }
10122 205 }
10123
10124
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10125 {
10126
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10127 {
10128 return qe_invalid;
10129 }
10130
10131
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10132 {
10133 return qe_invalid;
10134 }
10135
10136
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10137 {
10138 return qe_invalid;
10139 }
10140
10141 820 divespr[i][spr_tile]=(int32_t)tile;
10142 820 divespr[i][spr_flip]=(int32_t)flip;
10143 820 divespr[i][spr_extend]=(int32_t)extend;
10144 820 }
10145
10146
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10147 {
10148
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10149 {
10150 return qe_invalid;
10151 }
10152
10153
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10154 {
10155 return qe_invalid;
10156 }
10157
10158
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10159 {
10160 return qe_invalid;
10161 }
10162
10163 820 poundspr[i][spr_tile]=(int32_t)tile;
10164 820 poundspr[i][spr_flip]=(int32_t)flip;
10165 820 poundspr[i][spr_extend]=(int32_t)extend;
10166 820 }
10167
10168
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&tile,f))
10169 {
10170 return qe_invalid;
10171 }
10172
10173 205 flip=0;
10174
10175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(v_herosprites>0)
10176 {
10177
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_getc(&flip,f))
10178 {
10179 return qe_invalid;
10180 }
10181 205 }
10182
10183
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_getc(&extend,f))
10184 {
10185 return qe_invalid;
10186 }
10187
10188 205 castingspr[spr_tile]=(int32_t)tile;
10189 205 castingspr[spr_flip]=(int32_t)flip;
10190 205 castingspr[spr_extend]=(int32_t)extend;
10191
10192
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(v_herosprites>0)
10193 {
10194 205 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10195
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 205 times.
615 for(int32_t i=0; i<2; i++)
10196 {
10197
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 410 times.
1230 for(int32_t j=0; j<num_holdsprs; j++)
10198 {
10199
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10200 {
10201 return qe_invalid;
10202 }
10203
10204
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10205 {
10206 return qe_invalid;
10207 }
10208
10209
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10210 {
10211 return qe_invalid;
10212 }
10213
10214 820 holdspr[i][j][spr_tile]=(int32_t)tile;
10215 820 holdspr[i][j][spr_flip]=(int32_t)flip;
10216 820 holdspr[i][j][spr_extend]=(int32_t)extend;
10217 820 }
10218 410 }
10219 205 }
10220 else
10221 {
10222 for(int32_t i=0; i<2; i++)
10223 {
10224 if(!p_igetw(&tile,f))
10225 {
10226 return qe_invalid;
10227 }
10228
10229 if(!p_igetw(&tile2,f))
10230 {
10231 return qe_invalid;
10232 }
10233
10234 if(!p_getc(&extend,f))
10235 {
10236 return qe_invalid;
10237 }
10238
10239 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10240 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10241 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10242 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10243 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10244 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10245 }
10246 }
10247
10248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(v_herosprites>2)
10249 {
10250
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10251 {
10252
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10253 {
10254 return qe_invalid;
10255 }
10256
10257
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10258 {
10259 return qe_invalid;
10260 }
10261
10262
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10263 {
10264 return qe_invalid;
10265 }
10266
10267 820 jumpspr[i][spr_tile]=(int32_t)tile;
10268 820 jumpspr[i][spr_flip]=(int32_t)flip;
10269 820 jumpspr[i][spr_extend]=(int32_t)extend;
10270 820 }
10271 205 }
10272
10273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(v_herosprites>3)
10274 {
10275
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10276 {
10277
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10278 {
10279 return qe_invalid;
10280 }
10281
10282
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10283 {
10284 return qe_invalid;
10285 }
10286
10287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 820 times.
820 if(!p_getc(&extend,f))
10288 {
10289 return qe_invalid;
10290 }
10291
10292 820 chargespr[i][spr_tile]=(int32_t)tile;
10293 820 chargespr[i][spr_flip]=(int32_t)flip;
10294 820 chargespr[i][spr_extend]=(int32_t)extend;
10295 820 }
10296 205 }
10297
10298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(v_herosprites>4)
10299 {
10300
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_getc(&dummy_byte,f))
10301 {
10302 return qe_invalid;
10303 }
10304
10305 205 zinit.hero_swim_speed=(byte)dummy_byte;
10306 205 }
10307
10308 205 memset(frozenspr, 0, sizeof(frozenspr));
10309 205 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10310 205 memset(onfirespr, 0, sizeof(onfirespr));
10311 205 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10312 205 memset(diggingspr, 0, sizeof(diggingspr));
10313 205 memset(usingrodspr, 0, sizeof(usingrodspr));
10314 205 memset(usingcanespr, 0, sizeof(usingcanespr));
10315 205 memset(pushingspr, 0, sizeof(pushingspr));
10316 205 memset(liftingspr, 0, sizeof(liftingspr));
10317 205 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10318 205 memset(stunnedspr, 0, sizeof(stunnedspr));
10319 205 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10320 205 memset(fallingspr, 0, sizeof(fallingspr));
10321 205 memset(shockedspr, 0, sizeof(shockedspr));
10322 205 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10323 205 memset(pullswordspr, 0, sizeof(pullswordspr));
10324 205 memset(readingspr, 0, sizeof(readingspr));
10325 205 memset(slash180spr, 0, sizeof(slash180spr));
10326 205 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10327 205 memset(dashspr, 0, sizeof(dashspr));
10328 205 memset(bonkspr, 0, sizeof(bonkspr));
10329 205 memset(medallionsprs, 0, sizeof(medallionsprs));
10330 205 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10331 205 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10332
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t q = 0; q < 4; ++q)
10333 {
10334
2/2
✓ Branch 0 taken 2460 times.
✓ Branch 1 taken 820 times.
3280 for(int32_t p = 0; p < 3; ++p)
10335 {
10336 2460 drowningspr[q][p] = divespr[q][p];
10337 2460 drowning_lavaspr[q][p] = divespr[q][p];
10338 2460 }
10339 820 }
10340 205 memset(sideswimspr, 0, sizeof(sideswimspr));
10341 205 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10342 205 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10343 205 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10344 205 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10345 205 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10346 205 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10347 205 }
10348
10349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 310 times.
310 if(FFCore.quest_format[vInitData] < 34)
10350 {
10351 310 bool fastswim = zinit.hero_swim_speed > 60;
10352 // '2/3' or '1/2'
10353 310 zinit.hero_swim_mult = fastswim ? 2 : 1;
10354 310 zinit.hero_swim_div = fastswim ? 3 : 2;
10355 310 }
10356 310 return 0;
10357 310 }
10358
10359 30430 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10360 {
10361 30430 arr[spr_tile] = tile;
10362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30430 times.
30430 arr[spr_flip] = (flip > 3 ? 0 : flip);
10363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30430 times.
30430 arr[spr_extend] = (ext > 2 ? 0 : ext);
10364 30430 }
10365 //Used to read the player sprites as int32_t, not word.
10366 179 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites)
10367 {
10368 179 zinit.hero_swim_speed=67; //default
10369 179 setupherotiles(zinit.heroAnimationStyle);
10370 179 setupherodefenses();
10371 179 setupherooffsets();
10372
10373 int32_t tile, tile2;
10374 byte flip, extend, dummy_byte;
10375
10376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 179 times.
179 if(v_herosprites>=0)
10377 {
10378
10379
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t i=0; i<4; i++)
10380 {
10381
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10382 {
10383 return qe_invalid;
10384 }
10385
10386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&flip,f))
10387 {
10388 return qe_invalid;
10389 }
10390
10391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
10392 {
10393 return qe_invalid;
10394 }
10395
10396 716 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10397 716 }
10398
10399
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t i=0; i<4; i++)
10400 {
10401
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10402 {
10403 return qe_invalid;
10404 }
10405
10406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&flip,f))
10407 {
10408 return qe_invalid;
10409 }
10410
10411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
10412 {
10413 return qe_invalid;
10414 }
10415
10416 716 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10417 716 }
10418
10419
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t i=0; i<4; i++)
10420 {
10421
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10422 {
10423 return qe_invalid;
10424 }
10425
10426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&flip,f))
10427 {
10428 return qe_invalid;
10429 }
10430
10431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
10432 {
10433 return qe_invalid;
10434 }
10435
10436 716 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10437 716 }
10438
10439
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t i=0; i<4; i++)
10440 {
10441
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10442 {
10443 return qe_invalid;
10444 }
10445
10446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&flip,f))
10447 {
10448 return qe_invalid;
10449 }
10450
10451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
10452 {
10453 return qe_invalid;
10454 }
10455
10456 716 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10457 716 }
10458
10459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 179 times.
179 if(v_herosprites>1)
10460 {
10461
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t i=0; i<4; i++)
10462 {
10463
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10464 {
10465 return qe_invalid;
10466 }
10467
10468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&flip,f))
10469 {
10470 return qe_invalid;
10471 }
10472
10473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
10474 {
10475 return qe_invalid;
10476 }
10477
10478 716 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10479 716 }
10480 179 }
10481
10482
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t i=0; i<4; i++)
10483 {
10484
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10485 {
10486 return qe_invalid;
10487 }
10488
10489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&flip,f))
10490 {
10491 return qe_invalid;
10492 }
10493
10494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
10495 {
10496 return qe_invalid;
10497 }
10498
10499 716 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10500 716 }
10501
10502
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t i=0; i<4; i++)
10503 {
10504
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10505 {
10506 return qe_invalid;
10507 }
10508
10509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&flip,f))
10510 {
10511 return qe_invalid;
10512 }
10513
10514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
10515 {
10516 return qe_invalid;
10517 }
10518
10519 716 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10520 716 }
10521
10522
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(!p_igetl(&tile,f))
10523 {
10524 return qe_invalid;
10525 }
10526
10527 179 flip=0;
10528
10529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 179 times.
179 if(v_herosprites>0)
10530 {
10531
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(!p_getc(&flip,f))
10532 {
10533 return qe_invalid;
10534 }
10535 179 }
10536
10537
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(!p_getc(&extend,f))
10538 {
10539 return qe_invalid;
10540 }
10541
10542 179 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10543
10544
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(v_herosprites>0)
10545 {
10546 179 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10547
2/2
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 179 times.
537 for(int32_t i=0; i<2; i++)
10548 {
10549
2/2
✓ Branch 0 taken 1074 times.
✓ Branch 1 taken 358 times.
1432 for(int32_t j=0; j<num_holdsprs; j++)
10550 {
10551
1/2
✓ Branch 0 taken 1074 times.
✗ Branch 1 not taken.
1074 if(!p_igetl(&tile,f))
10552 {
10553 return qe_invalid;
10554 }
10555
10556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1074 times.
1074 if(!p_getc(&flip,f))
10557 {
10558 return qe_invalid;
10559 }
10560
10561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1074 times.
1074 if(!p_getc(&extend,f))
10562 {
10563 return qe_invalid;
10564 }
10565
10566 1074 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10567 1074 }
10568 358 }
10569 179 }
10570 else
10571 {
10572 for(int32_t i=0; i<2; i++)
10573 {
10574 if(!p_igetl(&tile,f))
10575 {
10576 return qe_invalid;
10577 }
10578
10579 if(!p_igetl(&tile2,f))
10580 {
10581 return qe_invalid;
10582 }
10583
10584 if(!p_getc(&extend,f))
10585 {
10586 return qe_invalid;
10587 }
10588
10589 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10590 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10591 }
10592 }
10593
10594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 179 times.
179 if(v_herosprites>2)
10595 {
10596
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t i=0; i<4; i++)
10597 {
10598
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10599 {
10600 return qe_invalid;
10601 }
10602
10603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&flip,f))
10604 {
10605 return qe_invalid;
10606 }
10607
10608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
10609 {
10610 return qe_invalid;
10611 }
10612
10613 716 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10614 716 }
10615 179 }
10616
10617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 179 times.
179 if(v_herosprites>3)
10618 {
10619
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t i=0; i<4; i++)
10620 {
10621
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10622 {
10623 return qe_invalid;
10624 }
10625
10626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&flip,f))
10627 {
10628 return qe_invalid;
10629 }
10630
10631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
10632 {
10633 return qe_invalid;
10634 }
10635
10636 716 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10637 716 }
10638 179 }
10639
10640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 179 times.
179 if(v_herosprites>4)
10641 {
10642
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(!p_getc(&dummy_byte,f))
10643 {
10644 return qe_invalid;
10645 }
10646
10647 179 zinit.hero_swim_speed=(byte)dummy_byte;
10648 179 }
10649
10650
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(v_herosprites>6)
10651 {
10652
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
10653 {
10654
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10655 return qe_invalid;
10656
10657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&flip,f))
10658 return qe_invalid;
10659
10660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
10661 return qe_invalid;
10662
10663 716 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10664 716 }
10665
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
10666 {
10667
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10668 return qe_invalid;
10669
10670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&flip,f))
10671 return qe_invalid;
10672
10673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
10674 return qe_invalid;
10675
10676 716 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10677 716 }
10678
10679
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
10680 {
10681
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10682 return qe_invalid;
10683
10684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&flip,f))
10685 return qe_invalid;
10686
10687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
10688 return qe_invalid;
10689
10690 716 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10691 716 }
10692
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
10693 {
10694
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10695 return qe_invalid;
10696
10697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&flip,f))
10698 return qe_invalid;
10699
10700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
10701 return qe_invalid;
10702
10703 716 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10704 716 }
10705
10706
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
10707 {
10708
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10709 return qe_invalid;
10710
10711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&flip,f))
10712 return qe_invalid;
10713
10714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
10715 return qe_invalid;
10716
10717 716 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10718 716 }
10719
10720
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
10721 {
10722
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10723 return qe_invalid;
10724
10725
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&flip,f))
10726 return qe_invalid;
10727
10728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
10729 return qe_invalid;
10730
10731 716 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10732 716 }
10733
10734
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
10735 {
10736
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10737 return qe_invalid;
10738
10739
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&flip,f))
10740 return qe_invalid;
10741
10742
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&extend,f))
10743 return qe_invalid;
10744
10745 716 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10746 716 }
10747
10748
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
10749 {
10750
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10751 return qe_invalid;
10752
10753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&flip,f))
10754 return qe_invalid;
10755
10756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
10757 return qe_invalid;
10758
10759 716 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10760 716 }
10761
10762
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
10763 {
10764
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10765 return qe_invalid;
10766
10767
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&flip,f))
10768 return qe_invalid;
10769
10770
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&extend,f))
10771 return qe_invalid;
10772
10773 716 byte frames = 0;
10774
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 696 times.
716 if(v_herosprites > 15)
10775 {
10776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 696 times.
696 if(!p_getc(&frames,f))
10777 return qe_invalid;
10778 696 }
10779
10780 716 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10781 716 liftingspr[q][spr_frames] = frames;
10782 716 }
10783
10784
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
10785 {
10786
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10787 return qe_invalid;
10788
10789
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&flip,f))
10790 return qe_invalid;
10791
10792
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&extend,f))
10793 return qe_invalid;
10794
10795 716 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10796 716 }
10797
10798
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
10799 {
10800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_igetl(&tile,f))
10801 return qe_invalid;
10802
10803
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&flip,f))
10804 return qe_invalid;
10805
10806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
10807 return qe_invalid;
10808
10809 716 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10810 716 }
10811
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
10812 {
10813
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10814 return qe_invalid;
10815
10816
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&flip,f))
10817 return qe_invalid;
10818
10819
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&extend,f))
10820 return qe_invalid;
10821
10822 716 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10823 716 }
10824
10825
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
10826 {
10827
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10828 return qe_invalid;
10829
10830
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&flip,f))
10831 return qe_invalid;
10832
10833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
10834 return qe_invalid;
10835
10836 716 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10837 716 }
10838
10839
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
10840 {
10841
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10842 return qe_invalid;
10843
10844
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&flip,f))
10845 return qe_invalid;
10846
10847
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&extend,f))
10848 return qe_invalid;
10849
10850 716 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10851 716 }
10852
10853
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
10854 {
10855
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10856 return qe_invalid;
10857
10858
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&flip,f))
10859 return qe_invalid;
10860
10861
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&extend,f))
10862 return qe_invalid;
10863
10864 716 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10865 716 }
10866
10867
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
10868 {
10869
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10870 return qe_invalid;
10871
10872
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&flip,f))
10873 return qe_invalid;
10874
10875
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&extend,f))
10876 return qe_invalid;
10877
10878 716 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10879 716 }
10880
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
10881 {
10882
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10883 return qe_invalid;
10884
10885
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&flip,f))
10886 return qe_invalid;
10887
10888
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&extend,f))
10889 return qe_invalid;
10890
10891 716 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10892 716 }
10893
10894
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
10895 {
10896
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10897 return qe_invalid;
10898
10899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&flip,f))
10900 return qe_invalid;
10901
10902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
10903 return qe_invalid;
10904
10905 716 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10906 716 }
10907
10908
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
10909 {
10910
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10911 return qe_invalid;
10912
10913
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&flip,f))
10914 return qe_invalid;
10915
10916
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&extend,f))
10917 return qe_invalid;
10918
10919 716 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10920 716 }
10921
10922
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
10923 {
10924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_igetl(&tile,f))
10925 return qe_invalid;
10926
10927
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&flip,f))
10928 return qe_invalid;
10929
10930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
10931 return qe_invalid;
10932
10933 716 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10934 716 }
10935
10936
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
10937 {
10938
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10939 return qe_invalid;
10940
10941
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&flip,f))
10942 return qe_invalid;
10943
10944
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&extend,f))
10945 return qe_invalid;
10946
10947 716 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10948 716 }
10949
10950
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
10951 {
10952
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10953 return qe_invalid;
10954
10955
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&flip,f))
10956 return qe_invalid;
10957
10958
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&extend,f))
10959 return qe_invalid;
10960
10961 716 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10962 716 }
10963
10964
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
10965 {
10966
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
10967 return qe_invalid;
10968
10969
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&flip,f))
10970 return qe_invalid;
10971
10972
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_getc(&extend,f))
10973 return qe_invalid;
10974
10975 716 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10976 716 }
10977
10978
2/2
✓ Branch 0 taken 537 times.
✓ Branch 1 taken 179 times.
716 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10979 {
10980
1/2
✓ Branch 0 taken 537 times.
✗ Branch 1 not taken.
537 if(!p_igetl(&tile,f))
10981 return qe_invalid;
10982
10983
1/2
✓ Branch 0 taken 537 times.
✗ Branch 1 not taken.
537 if(!p_getc(&flip,f))
10984 return qe_invalid;
10985
10986
1/2
✓ Branch 0 taken 537 times.
✗ Branch 1 not taken.
537 if(!p_getc(&extend,f))
10987 return qe_invalid;
10988
10989 537 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10990 537 }
10991 179 }
10992 else
10993 {
10994 memset(frozenspr, 0, sizeof(frozenspr));
10995 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10996 memset(onfirespr, 0, sizeof(onfirespr));
10997 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10998 memset(diggingspr, 0, sizeof(diggingspr));
10999 memset(usingrodspr, 0, sizeof(usingrodspr));
11000 memset(usingcanespr, 0, sizeof(usingcanespr));
11001 memset(pushingspr, 0, sizeof(pushingspr));
11002 memset(liftingspr, 0, sizeof(liftingspr));
11003 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
11004 memset(stunnedspr, 0, sizeof(stunnedspr));
11005 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
11006 memset(fallingspr, 0, sizeof(fallingspr));
11007 memset(shockedspr, 0, sizeof(shockedspr));
11008 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
11009 memset(pullswordspr, 0, sizeof(pullswordspr));
11010 memset(readingspr, 0, sizeof(readingspr));
11011 memset(slash180spr, 0, sizeof(slash180spr));
11012 memset(slashZ4spr, 0, sizeof(slashZ4spr));
11013 memset(dashspr, 0, sizeof(dashspr));
11014 memset(bonkspr, 0, sizeof(bonkspr));
11015 memset(medallionsprs, 0, sizeof(medallionsprs));
11016 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11017 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11018 for(int32_t q = 0; q < 4; ++q)
11019 {
11020 for(int32_t p = 0; p < 3; ++p)
11021 {
11022 drowningspr[q][p] = divespr[q][p];
11023 drowning_lavaspr[q][p] = divespr[q][p];
11024 }
11025 }
11026 }
11027
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if (v_herosprites > 8)
11028 {
11029
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
11030 {
11031
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
11032 return qe_invalid;
11033
11034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&flip,f))
11035 return qe_invalid;
11036
11037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
11038 return qe_invalid;
11039
11040 716 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11041 716 }
11042 179 }
11043 else
11044 {
11045 memset(sideswimspr, 0, sizeof(sideswimspr));
11046 }
11047
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if (v_herosprites > 9)
11048 {
11049
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
11050 {
11051
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
11052 return qe_invalid;
11053
11054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&flip,f))
11055 return qe_invalid;
11056
11057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
11058 return qe_invalid;
11059
11060 716 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11061 716 }
11062
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
11063 {
11064
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
11065 return qe_invalid;
11066
11067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&flip,f))
11068 return qe_invalid;
11069
11070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
11071 return qe_invalid;
11072
11073 716 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11074 716 }
11075
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
11076 {
11077
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
11078 return qe_invalid;
11079
11080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&flip,f))
11081 return qe_invalid;
11082
11083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
11084 return qe_invalid;
11085
11086 716 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11087 716 }
11088
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
11089 {
11090
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
11091 return qe_invalid;
11092
11093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&flip,f))
11094 return qe_invalid;
11095
11096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
11097 return qe_invalid;
11098
11099 716 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11100 716 }
11101 179 }
11102 else
11103 {
11104 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11105 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11106 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11107 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11108 }
11109
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if (v_herosprites > 10)
11110 {
11111
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
11112 {
11113 int32_t hmr;
11114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_igetl(&hmr,f))
11115 return qe_invalid;
11116
11117 716 hammeroffsets[q] = hmr;
11118 716 }
11119 179 }
11120 else
11121 {
11122 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11123 }
11124
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if (v_herosprites > 11)
11125 {
11126
2/2
✓ Branch 0 taken 537 times.
✓ Branch 1 taken 179 times.
716 for(int32_t q = 0; q < 3; ++q)
11127 {
11128
1/2
✓ Branch 0 taken 537 times.
✗ Branch 1 not taken.
537 if(!p_igetl(&tile,f))
11129 return qe_invalid;
11130
11131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 537 times.
537 if(!p_getc(&flip,f))
11132 return qe_invalid;
11133
11134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 537 times.
537 if(!p_getc(&extend,f))
11135 return qe_invalid;
11136
11137 537 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11138 537 }
11139 179 }
11140 else
11141 {
11142 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11143 }
11144
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if (v_herosprites > 12)
11145 {
11146
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(!p_igetl(&tile,f))
11147 return qe_invalid;
11148
11149
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(!p_getc(&flip,f))
11150 return qe_invalid;
11151
11152
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(!p_getc(&extend,f))
11153 return qe_invalid;
11154 179 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11155
11156 179 }
11157 else
11158 {
11159 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11160 }
11161
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if (v_herosprites > 13)
11162 {
11163
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
11164 {
11165
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
11166 return qe_invalid;
11167
11168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&flip,f))
11169 return qe_invalid;
11170
11171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
11172 return qe_invalid;
11173
11174 716 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11175 716 }
11176 179 }
11177 else
11178 {
11179 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11180 }
11181
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if (v_herosprites > 14)
11182 {
11183
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int32_t q = 0; q < 4; ++q)
11184 {
11185
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tile,f))
11186 return qe_invalid;
11187
11188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&flip,f))
11189 return qe_invalid;
11190
11191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(!p_getc(&extend,f))
11192 return qe_invalid;
11193
11194 716 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11195 716 }
11196 179 }
11197 else
11198 {
11199 memset(revslashspr, 0, sizeof(revslashspr));
11200 }
11201
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if (v_herosprites > 7)
11202 {
11203 179 int32_t num_defense = wMax;
11204 179 byte def = 0;
11205
11206 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11207 /*if(v_herosprites > [x])
11208 * {
11209 * num_defense = 146 //value of wMax on version 8
11210 * }
11211 */
11212
11213
2/2
✓ Branch 0 taken 26134 times.
✓ Branch 1 taken 179 times.
26313 for (int32_t q = 0; q < num_defense; q++)
11214 {
11215
1/2
✓ Branch 0 taken 26134 times.
✗ Branch 1 not taken.
26134 if (!p_getc(&def, f))
11216 return qe_invalid;
11217
11218 26134 hero_defence[q] = def;
11219 26134 }
11220 179 }
11221 else
11222 {
11223 int32_t num_defense = wMax;
11224 for (int32_t q = 0; q < num_defense; q++)
11225 {
11226 hero_defence[q] = 0;
11227 }
11228 }
11229 179 }
11230
11231
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 11 times.
179 if(FFCore.quest_format[vInitData] < 34)
11232 {
11233 11 bool fastswim = zinit.hero_swim_speed > 60;
11234 // '2/3' or '1/2'
11235 11 zinit.hero_swim_mult = fastswim ? 2 : 1;
11236 11 zinit.hero_swim_div = fastswim ? 3 : 2;
11237 11 }
11238 179 return 0;
11239 179 }
11240
11241
11242 384 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11243 {
11244 //these are here to bypass compiler warnings about unused arguments
11245 384 Header=Header;
11246
11247 dword dummy;
11248 384 word s_version=0;
11249
11250 //section version info
11251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_igetw(&s_version,f))
11252 {
11253 return qe_invalid;
11254 }
11255
11256 384 FFCore.quest_format[vHeroSprites] = s_version;
11257
11258
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!read_deprecated_section_cversion(f))
11259 {
11260 return qe_invalid;
11261 }
11262
11263 //section size
11264
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetl(&dummy,f))
11265 {
11266 return qe_invalid;
11267 }
11268
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 205 times.
384 if ( s_version >= 6 )
11269 {
11270 179 return readherosprites3(f, s_version);
11271 }
11272 205 else return readherosprites2(f, s_version);
11273 384 }
11274
11275 222 int32_t read_old_subscreens(PACKFILE *f, word s_version)
11276 {
11277 222 subscreens_active.clear();
11278 222 subscreens_passive.clear();
11279 222 subscreens_overlay.clear();
11280
2/2
✓ Branch 0 taken 28416 times.
✓ Branch 1 taken 222 times.
28638 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11281 {
11282 subscreen_group g;
11283 28416 memset(&g,0,sizeof(subscreen_group));
11284 28416 int32_t ret = read_one_old_subscreen(f, &g, s_version);
11285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28416 times.
28416 if(ret!=0)
11286 return ret;
11287
2/2
✓ Branch 0 taken 1161 times.
✓ Branch 1 taken 27255 times.
28416 if(g.objects[0].type == ssoNULL) continue;
11288
2/2
✓ Branch 0 taken 485 times.
✓ Branch 1 taken 676 times.
1161 auto& vec = g.ss_type == sstPASSIVE ? subscreens_passive : subscreens_active;
11289 1161 ZCSubscreen& sub = vec.emplace_back();
11290 1161 sub.load_old(g);
11291 1161 }
11292
11293 222 return 0;
11294 222 }
11295
11296 28416 int32_t read_one_old_subscreen(PACKFILE *f, subscreen_group* g, word s_version)
11297 {
11298 28416 int32_t numsub=0;
11299 28416 byte temp_ss=0;
11300 subscreen_object temp_sub_stack;
11301 28416 subscreen_object *temp_sub = &temp_sub_stack;
11302
11303 char tempname[64];
11304
11305 // FWIW I never saw anything bigger than 20.
11306 #define MAX_DP1_LEN 1024
11307 char tempdp1[MAX_DP1_LEN];
11308
11309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28416 times.
28416 if(!pfread(tempname,64,f))
11310 {
11311 return qe_invalid;
11312 }
11313
11314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28416 times.
28416 if(s_version > 1)
11315 {
11316
1/2
✓ Branch 0 taken 28416 times.
✗ Branch 1 not taken.
28416 if(!p_getc(&temp_ss,f))
11317 {
11318 return qe_invalid;
11319 }
11320 28416 }
11321
11322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28416 times.
28416 if(s_version < 4)
11323 {
11324 uint8_t tmp=0;
11325
11326 if(!p_getc(&tmp,f))
11327 {
11328 return qe_invalid;
11329 }
11330
11331 numsub = (int32_t)tmp;
11332 }
11333 else
11334 {
11335 word tmp;
11336
11337
1/2
✓ Branch 0 taken 28416 times.
✗ Branch 1 not taken.
28416 if(!p_igetw(&tmp, f))
11338 {
11339 return qe_invalid;
11340 }
11341
11342 28416 numsub = (int32_t)tmp;
11343 }
11344
11345 int32_t j;
11346
11347
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 75277 times.
✓ Branch 2 taken 46861 times.
✓ Branch 3 taken 28416 times.
75277 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11348 {
11349 46861 memset(temp_sub,0,sizeof(subscreen_object));
11350
11351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46861 times.
46861 switch(g->objects[j].type)
11352 {
11353 case ssoTEXT:
11354 case ssoTEXTBOX:
11355 case ssoCURRENTITEMTEXT:
11356 case ssoCURRENTITEMCLASSTEXT:
11357 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11358
11359 //fall through
11360 default:
11361 46861 memset(&g->objects[j],0,sizeof(subscreen_object));
11362 46861 break;
11363 }
11364
11365
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->type),f))
11366 return qe_invalid;
11367
11368
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->pos),f))
11369 return qe_invalid;
11370
11371
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(s_version < 5)
11372 {
11373 switch(temp_sub->pos)
11374 {
11375 case 0:
11376 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11377 break;
11378
11379 case 1:
11380 temp_sub->pos = sspUP;
11381 break;
11382
11383 case 2:
11384 temp_sub->pos = sspDOWN;
11385 break;
11386
11387 default:
11388 temp_sub->pos = 0;
11389 }
11390 }
11391
11392
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->x),f))
11393 return qe_invalid;
11394
11395
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->y),f))
11396 return qe_invalid;
11397
11398
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->w),f))
11399 return qe_invalid;
11400
11401
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->h),f))
11402 return qe_invalid;
11403
11404
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->colortype1),f))
11405 return qe_invalid;
11406
11407
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->color1),f))
11408 return qe_invalid;
11409
11410
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->colortype2),f))
11411 return qe_invalid;
11412
11413
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->color2),f))
11414 return qe_invalid;
11415
11416
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->colortype3),f))
11417 return qe_invalid;
11418
11419
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->color3),f))
11420 return qe_invalid;
11421
11422
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d1),f))
11423 return qe_invalid;
11424
11425
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d2),f))
11426 return qe_invalid;
11427
11428
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d3),f))
11429 return qe_invalid;
11430
11431
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d4),f))
11432 return qe_invalid;
11433
11434
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d5),f))
11435 return qe_invalid;
11436
11437
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d6),f))
11438 return qe_invalid;
11439
11440
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d7),f))
11441 return qe_invalid;
11442
11443
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d8),f))
11444 return qe_invalid;
11445
11446
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d9),f))
11447 return qe_invalid;
11448
11449
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d10),f))
11450 return qe_invalid;
11451
11452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46861 times.
46861 if(s_version < 2)
11453 {
11454 if(!p_igetl(&(temp_sub->speed),f))
11455 return qe_invalid;
11456
11457 if(!p_igetl(&(temp_sub->delay),f))
11458 return qe_invalid;
11459
11460 if(!p_igetl(&(temp_sub->frame),f))
11461 return qe_invalid;
11462 }
11463 else
11464 {
11465
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->speed),f))
11466 return qe_invalid;
11467
11468
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->delay),f))
11469 return qe_invalid;
11470
11471
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->frame),f))
11472 return qe_invalid;
11473 }
11474
11475 46861 int32_t temp_size=0;
11476
11477 // bool deletets = false;
11478
4/4
✓ Branch 0 taken 20828 times.
✓ Branch 1 taken 3482 times.
✓ Branch 2 taken 22301 times.
✓ Branch 3 taken 250 times.
46861 switch(temp_sub->type)
11479 {
11480 case ssoTEXT:
11481 case ssoTEXTBOX:
11482 case ssoCURRENTITEMTEXT:
11483 case ssoCURRENTITEMCLASSTEXT:
11484 {
11485 word temptempsize;
11486
11487
1/2
✓ Branch 0 taken 3482 times.
✗ Branch 1 not taken.
3482 if(!p_igetw(&temptempsize,f))
11488 {
11489 return qe_invalid;
11490 }
11491
11492 //temptempsize = temp1 + (temp2 << 8);
11493 3482 temp_size = (int32_t)temptempsize;
11494 3482 uint32_t char_length = temp_size+2;
11495
1/2
✓ Branch 0 taken 3482 times.
✗ Branch 1 not taken.
3482 if (char_length > MAX_DP1_LEN)
11496 {
11497 return qe_invalid;
11498 }
11499 3482 tempdp1[char_length - 1] = '\0';
11500
11501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3482 times.
3482 if(temp_size)
11502
1/2
✓ Branch 0 taken 3482 times.
✗ Branch 1 not taken.
3482 if(!pfread(tempdp1,temp_size+1,f))
11503 return qe_invalid;
11504 3482 break;
11505 }
11506
11507 case ssoLIFEMETER:
11508
1/2
✓ Branch 0 taken 250 times.
✗ Branch 1 not taken.
250 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11509 temp_sub->d3 = 1;
11510
11511
1/2
✓ Branch 0 taken 250 times.
✗ Branch 1 not taken.
250 if(!p_getc(&(temp_sub->dp1),f))
11512 return qe_invalid;
11513
11514 250 break;
11515
11516
11517 case ssoCURRENTITEM:
11518
11519
1/2
✓ Branch 0 taken 20828 times.
✗ Branch 1 not taken.
20828 if(s_version < 6)
11520 {
11521 switch(temp_sub->d1)
11522 {
11523 case ssiBOMB:
11524 temp_sub->d1 = itype_bomb;
11525 break;
11526
11527 case ssiSWORD:
11528 temp_sub->d1 = itype_sword;
11529 break;
11530
11531 case ssiSHIELD:
11532 temp_sub->d1 = itype_shield;
11533 break;
11534
11535 case ssiCANDLE:
11536 temp_sub->d1 = itype_candle;
11537 break;
11538
11539 case ssiLETTER:
11540 temp_sub->d1 = itype_letter;
11541 break;
11542
11543 case ssiPOTION:
11544 temp_sub->d1 = itype_potion;
11545 break;
11546
11547 case ssiLETTERPOTION:
11548 temp_sub->d1 = itype_letterpotion;
11549 break;
11550
11551 case ssiBOW:
11552 temp_sub->d1 = itype_bow;
11553 break;
11554
11555 case ssiARROW:
11556 temp_sub->d1 = itype_arrow;
11557 break;
11558
11559 case ssiBOWANDARROW:
11560 temp_sub->d1 = itype_bowandarrow;
11561 break;
11562
11563 case ssiBAIT:
11564 temp_sub->d1 = itype_bait;
11565 break;
11566
11567 case ssiRING:
11568 temp_sub->d1 = itype_ring;
11569 break;
11570
11571 case ssiBRACELET:
11572 temp_sub->d1 = itype_bracelet;
11573 break;
11574
11575 case ssiMAP:
11576 temp_sub->d1 = itype_map;
11577 break;
11578
11579 case ssiCOMPASS:
11580 temp_sub->d1 = itype_compass;
11581 break;
11582
11583 case ssiBOSSKEY:
11584 temp_sub->d1 = itype_bosskey;
11585 break;
11586
11587 case ssiMAGICKEY:
11588 temp_sub->d1 = itype_magickey;
11589 break;
11590
11591 case ssiBRANG:
11592 temp_sub->d1 = itype_brang;
11593 break;
11594
11595 case ssiWAND:
11596 temp_sub->d1 = itype_wand;
11597 break;
11598
11599 case ssiRAFT:
11600 temp_sub->d1 = itype_raft;
11601 break;
11602
11603 case ssiLADDER:
11604 temp_sub->d1 = itype_ladder;
11605 break;
11606
11607 case ssiWHISTLE:
11608 temp_sub->d1 = itype_whistle;
11609 break;
11610
11611 case ssiBOOK:
11612 temp_sub->d1 = itype_book;
11613 break;
11614
11615 case ssiWALLET:
11616 temp_sub->d1 = itype_wallet;
11617 break;
11618
11619 case ssiSBOMB:
11620 temp_sub->d1 = itype_sbomb;
11621 break;
11622
11623 case ssiHCPIECE:
11624 temp_sub->d1 = itype_heartpiece;
11625 break;
11626
11627 case ssiAMULET:
11628 temp_sub->d1 = itype_amulet;
11629 break;
11630
11631 case ssiFLIPPERS:
11632 temp_sub->d1 = itype_flippers;
11633 break;
11634
11635 case ssiHOOKSHOT:
11636 temp_sub->d1 = itype_hookshot;
11637 break;
11638
11639 case ssiLENS:
11640 temp_sub->d1 = itype_lens;
11641 break;
11642
11643 case ssiHAMMER:
11644 temp_sub->d1 = itype_hammer;
11645 break;
11646
11647 case ssiBOOTS:
11648 temp_sub->d1 = itype_boots;
11649 break;
11650
11651 case ssiDIVINEFIRE:
11652 temp_sub->d1 = itype_divinefire;
11653 break;
11654
11655 case ssiDIVINEESCAPE:
11656 temp_sub->d1 = itype_divineescape;
11657 break;
11658
11659 case ssiDIVINEPROTECTION:
11660 temp_sub->d1 = itype_divineprotection;
11661 break;
11662
11663 case ssiQUIVER:
11664 temp_sub->d1 = itype_quiver;
11665 break;
11666
11667 case ssiBOMBBAG:
11668 temp_sub->d1 = itype_bombbag;
11669 break;
11670
11671 case ssiCBYRNA:
11672 temp_sub->d1 = itype_cbyrna;
11673 break;
11674
11675 case ssiROCS:
11676 temp_sub->d1 = itype_rocs;
11677 break;
11678
11679 case ssiHOVERBOOTS:
11680 temp_sub->d1 = itype_hoverboots;
11681 break;
11682
11683 case ssiSPINSCROLL:
11684 temp_sub->d1 = itype_spinscroll;
11685 break;
11686
11687 case ssiCROSSSCROLL:
11688 temp_sub->d1 = itype_crossscroll;
11689 break;
11690
11691 case ssiQUAKESCROLL:
11692 temp_sub->d1 = itype_quakescroll;
11693 break;
11694
11695 case ssiWHISPRING:
11696 temp_sub->d1 = itype_whispring;
11697 break;
11698
11699 case ssiCHARGERING:
11700 temp_sub->d1 = itype_chargering;
11701 break;
11702
11703 case ssiPERILSCROLL:
11704 temp_sub->d1 = itype_perilscroll;
11705 break;
11706
11707 case ssiWEALTHMEDAL:
11708 temp_sub->d1 = itype_wealthmedal;
11709 break;
11710
11711 case ssiHEARTRING:
11712 temp_sub->d1 = itype_heartring;
11713 break;
11714
11715 case ssiMAGICRING:
11716 temp_sub->d1 = itype_magicring;
11717 break;
11718
11719 case ssiSPINSCROLL2:
11720 temp_sub->d1 = itype_spinscroll2;
11721 break;
11722
11723 case ssiQUAKESCROLL2:
11724 temp_sub->d1 = itype_quakescroll2;
11725 break;
11726
11727 case ssiAGONY:
11728 temp_sub->d1 = itype_agony;
11729 break;
11730
11731 case ssiSTOMPBOOTS:
11732 temp_sub->d1 = itype_stompboots;
11733 break;
11734
11735 case ssiWHIMSICALRING:
11736 temp_sub->d1 = itype_whimsicalring;
11737 break;
11738
11739 case ssiPERILRING:
11740 temp_sub->d1 = itype_perilring;
11741 break;
11742
11743 default:
11744 temp_sub->d1 += itype_custom1 - ssiMAX;
11745 }
11746 }
11747
11748 //fall-through
11749 default:
11750
1/2
✓ Branch 0 taken 43129 times.
✗ Branch 1 not taken.
43129 if(!p_getc(&(temp_sub->dp1),f))
11751 return qe_invalid;
11752
11753 43129 break;
11754 }
11755
11756
2/2
✓ Branch 0 taken 8694 times.
✓ Branch 1 taken 38167 times.
46861 if(s_version < 7)
11757 {
11758
3/3
✓ Branch 0 taken 32010 times.
✓ Branch 1 taken 1389 times.
✓ Branch 2 taken 4768 times.
38167 switch(temp_sub->type)
11759 {
11760 case ssoMAGICGAUGE:
11761 {
11762
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1248 times.
1389 if(!temp_sub->d9)
11763 1248 temp_sub->d9 = -1; //-1 now represents 'always'
11764 1389 break;
11765 }
11766 case ssoLIFEGAUGE:
11767 4768 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11768 4768 break;
11769 }
11770 38167 }
11771
11772
3/3
✓ Branch 0 taken 3482 times.
✓ Branch 1 taken 41785 times.
✓ Branch 2 taken 1594 times.
46861 switch(temp_sub->type)
11773 {
11774 case ssoTEXT:
11775 case ssoTEXTBOX:
11776 case ssoCURRENTITEMTEXT:
11777 case ssoCURRENTITEMCLASSTEXT:
11778
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3482 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3482 if(g->objects[j].dp1 != NULL) delete[](char *)g->objects[j].dp1;
11779
11780 3482 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11781 3482 g->objects[j].dp1 = new char[temp_size+2];
11782 3482 strcpy((char*)g->objects[j].dp1,tempdp1);
11783 3482 break;
11784
11785 case ssoCOUNTER:
11786
1/2
✓ Branch 0 taken 1594 times.
✗ Branch 1 not taken.
1594 if(s_version<3)
11787 {
11788 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11789 temp_sub->d8=0;
11790 }
11791
11792 default:
11793 43379 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11794 43379 break;
11795 }
11796
11797 46861 g->name[0] = '\0';
11798 46861 strncat(g->name, tempname, 64 - 1);
11799 46861 g->ss_type = temp_ss;
11800 46861 }
11801
11802
2/2
✓ Branch 0 taken 7227635 times.
✓ Branch 1 taken 28416 times.
7256051 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11803 {
11804 //clear all unused object in this subscreen -DD
11805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7227635 times.
7227635 switch(g->objects[j].type)
11806 {
11807 case ssoTEXT:
11808 case ssoTEXTBOX:
11809 case ssoCURRENTITEMTEXT:
11810 case ssoCURRENTITEMCLASSTEXT:
11811 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11812
11813 //fall through
11814 default:
11815 7227635 memset(&g->objects[j],0,sizeof(subscreen_object));
11816 7227635 break;
11817 }
11818 7227635 }
11819
11820 28416 return 0;
11821 28416 }
11822
11823 384 int32_t readsubscreens(PACKFILE *f)
11824 {
11825 word s_version;
11826 dword dummy;
11827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_igetw(&s_version,f))
11828 return qe_invalid;
11829 384 FFCore.quest_format[vSubscreen] = s_version;
11830
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!read_deprecated_section_cversion(f))
11831 return qe_invalid;
11832
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetl(&dummy,f)) //section size
11833 return qe_invalid;
11834
11835
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 162 times.
384 if(s_version < 8)
11836 222 return read_old_subscreens(f,s_version);
11837
11838 162 subscreens_active.clear();
11839 162 subscreens_passive.clear();
11840 162 subscreens_overlay.clear();
11841
11842 byte sz;
11843
1/2
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
162 if(!p_getc(&sz,f))
11844 return qe_invalid;
11845
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 162 times.
685 for(byte q = 0; q < sz; ++q)
11846 {
11847 523 ZCSubscreen& tmp = subscreens_active.emplace_back();
11848
1/2
✓ Branch 0 taken 523 times.
✗ Branch 1 not taken.
523 if (auto ret = tmp.read(f, s_version))
11849 return ret;
11850 523 }
11851
1/2
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
162 if(!p_getc(&sz,f))
11852 return qe_invalid;
11853
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 162 times.
676 for(byte q = 0; q < sz; ++q)
11854 {
11855 514 ZCSubscreen& tmp = subscreens_passive.emplace_back();
11856
1/2
✓ Branch 0 taken 514 times.
✗ Branch 1 not taken.
514 if (auto ret = tmp.read(f, s_version))
11857 return ret;
11858 514 }
11859
1/2
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
162 if(!p_getc(&sz,f))
11860 return qe_invalid;
11861
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 162 times.
168 for(byte q = 0; q < sz; ++q)
11862 {
11863 6 ZCSubscreen& tmp = subscreens_overlay.emplace_back();
11864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (auto ret = tmp.read(f, s_version))
11865 return ret;
11866 6 }
11867 162 return 0;
11868 384 }
11869
11870 void reset_subscreen(subscreen_group *tempss)
11871 {
11872 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11873 {
11874 switch(tempss->objects[i].type)
11875 {
11876 case ssoTEXT:
11877 case ssoTEXTBOX:
11878 case ssoCURRENTITEMTEXT:
11879 case ssoCURRENTITEMCLASSTEXT:
11880 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11881
11882 //fall through
11883 default:
11884 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11885 break;
11886 }
11887 }
11888 }
11889
11890 116 void reset_subscreens()
11891 {
11892 116 subscreens_active.clear();
11893 116 subscreens_passive.clear();
11894 116 subscreens_overlay.clear();
11895 116 }
11896
11897 116 int32_t setupsubscreens()
11898 {
11899 116 reset_subscreens();
11900 //return 0;
11901
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 232 times.
348 for(int q = 0; q < 2; ++q)
11902 {
11903 232 subscreens_active.emplace_back();
11904 232 subscreens_passive.emplace_back();
11905 232 }
11906 116 int32_t tempsubscreen=subscr_mode;
11907
11908
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(tempsubscreen>=ssdtMAX)
11909 tempsubscreen=0;
11910
11911
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✗ Branch 2 not taken.
116 switch(tempsubscreen)
11912 {
11913 case ssdtOLD:
11914 case ssdtNEWSUBSCR:
11915 case ssdtREV2:
11916 case ssdtBSZELDA:
11917 case ssdtBSZELDAMODIFIED:
11918 case ssdtBSZELDAENHANCED:
11919 case ssdtBSZELDACOMPLETE:
11920 {
11921 116 subscreens_active[0].load_old(default_subscreen_active[tempsubscreen][0]);
11922 116 subscreens_active[0].sub_type=sstACTIVE;
11923 116 subscreens_active[0].name = "Active Subscreen (Triforce)";
11924 116 subscreens_active[1].load_old(default_subscreen_active[tempsubscreen][1]);
11925 116 subscreens_active[1].sub_type=sstACTIVE;
11926 116 subscreens_active[1].name = "Active Subscreen (Dungeon Map)";
11927 116 subscreens_passive[0].load_old(default_subscreen_passive[tempsubscreen][0]);
11928 116 subscreens_passive[0].sub_type=sstPASSIVE;
11929 116 subscreens_passive[0].name = "Passive Subscreen (Magic)";
11930 116 subscreens_passive[1].load_old(default_subscreen_passive[tempsubscreen][1]);
11931 116 subscreens_passive[1].sub_type=sstPASSIVE;
11932 116 subscreens_passive[1].name = "Passive Subscreen (No Magic)";
11933 116 break;
11934 }
11935
11936 case ssdtZ3:
11937 {
11938 subscreens_active[0].load_old(z3_active_a);
11939 subscreens_active[0].sub_type=sstACTIVE;
11940 subscreens_active[1].load_old(z3_active_ab);
11941 subscreens_active[1].sub_type=sstACTIVE;
11942 subscreens_passive[0].load_old(z3_passive_a);
11943 subscreens_passive[0].sub_type=sstPASSIVE;
11944 subscreens_passive[1].load_old(z3_passive_ab);
11945 subscreens_passive[1].sub_type=sstPASSIVE;
11946 break;
11947 }
11948 }
11949 116 subscr_mode = ssdtMAX;
11950 116 return 0;
11951 }
11952
11953 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
11954
11955 extern script_data *ffscripts[NUMSCRIPTFFC];
11956 extern script_data *itemscripts[NUMSCRIPTITEM];
11957 extern script_data *guyscripts[NUMSCRIPTGUYS];
11958 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
11959 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
11960 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
11961 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
11962 extern script_data *playerscripts[NUMSCRIPTHERO];
11963 extern script_data *screenscripts[NUMSCRIPTSCREEN];
11964 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
11965 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
11966 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
11967 extern script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
11968
11969 static std::vector<const script_data*> read_scripts;
11970
11971 462 int32_t readffscript(PACKFILE *f, zquestheader *Header)
11972 {
11973 int32_t dummy;
11974 462 word s_version=0, zmeta_version=0;
11975 462 byte numscripts=0;
11976 462 numscripts=numscripts; //to avoid unused variables warnings
11977 int32_t ret;
11978 462 read_scripts.clear();
11979 462 zasm_scripts.clear();
11980
11981 //section version info
11982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 462 times.
462 if(!p_igetw(&s_version,f))
11983 {
11984 return qe_invalid;
11985 }
11986
11987 462 FFCore.quest_format[vFFScript] = s_version;
11988
11989
1/2
✓ Branch 0 taken 462 times.
✗ Branch 1 not taken.
462 if(!read_deprecated_section_cversion(f))
11990 {
11991 return qe_invalid;
11992 }
11993
11994
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 179 times.
462 if(s_version >= 18)
11995 {
11996
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(!p_igetw(&zmeta_version,f))
11997 {
11998 return qe_invalid;
11999 }
12000 179 }
12001
12002 //section size
12003
1/2
✓ Branch 0 taken 462 times.
✗ Branch 1 not taken.
462 if(!p_igetl(&dummy,f))
12004 {
12005 return qe_invalid;
12006 }
12007
12008
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 224 times.
462 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12009 462 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12010
12011
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 114 times.
462 if(s_version >= 27)
12012 {
12013 114 ret = read_quest_zasm(f, s_version);
12014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(ret)
12015 return qe_invalid;
12016 114 }
12017
12018 //finally... section data
12019
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 412 times.
197020 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12020 {
12021 196608 ret = read_one_ffscript(f, Header, i, s_version, ffscripts[i], zmeta_version);
12022
12023
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if (ret)
12024 {
12025 return qe_invalid;
12026 }
12027 196608 }
12028
12029 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12030 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12031 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12032 * there was a version bump a week before a change that broke stuff.
12033 */
12034
7/8
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 233 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 179 times.
✓ Branch 5 taken 179 times.
✓ Branch 6 taken 179 times.
✓ Branch 7 taken 179 times.
412 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
12035 {
12036 591 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
12037 591 }
12038
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 205 times.
384 if(s_version < 19)
12039 {
12040 205 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
12041 205 }
12042
12043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(s_version > 1)
12044 {
12045
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 384 times.
98688 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12046 {
12047 98304 ret = read_one_ffscript(f, Header, i, s_version, itemscripts[i], zmeta_version);
12048
12049
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if (ret)
12050 {
12051 return qe_invalid;
12052 }
12053 98304 }
12054
12055
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 384 times.
98688 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12056 {
12057 98304 ret = read_one_ffscript(f, Header, i, s_version, guyscripts[i], zmeta_version);
12058
12059
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if (ret)
12060 {
12061 return qe_invalid;
12062 }
12063 98304 }
12064
12065
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 script_data *fake = new script_data(ScriptType::None, 0);
12066
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 384 times.
98688 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12067 {
12068 98304 ret = read_one_ffscript(f, Header, i, s_version, fake, zmeta_version);
12069
12070
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if (ret)
12071 {
12072 return qe_invalid;
12073 }
12074 98304 }
12075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 delete fake;
12076
12077
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 384 times.
98688 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12078 {
12079 98304 ret = read_one_ffscript(f, Header, i, s_version, screenscripts[i], zmeta_version);
12080
12081
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if (ret)
12082 {
12083 return qe_invalid;
12084 }
12085 98304 }
12086
12087
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 205 times.
384 if(s_version > 16)
12088 {
12089
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 179 times.
1611 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12090 {
12091 1432 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12092
12093
1/2
✓ Branch 0 taken 1432 times.
✗ Branch 1 not taken.
1432 if (ret)
12094 {
12095 return qe_invalid;
12096 }
12097 1432 }
12098 179 }
12099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 else if(s_version > 13)
12100 {
12101 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12102 {
12103 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12104
12105 if (ret)
12106 {
12107 return qe_invalid;
12108 }
12109 }
12110
12111 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12112 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12113
12114 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12115 }
12116
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 else if(s_version > 4)
12117 {
12118
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12119 {
12120 820 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12121
12122
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if (ret)
12123 {
12124 return qe_invalid;
12125 }
12126 820 }
12127
12128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12129
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12130
12131
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12132
12133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12134
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12135
12136
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12137
12138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12139
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 delete globalscripts[GLOBAL_SCRIPT_F6];
12140
12141
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12142
12143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12144
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12145
12146
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12147 205 }
12148 else
12149 {
12150 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12151 {
12152 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12153
12154 if (ret)
12155 {
12156 return qe_invalid;
12157 }
12158 }
12159
12160 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12161 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12162
12163 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVELOAD);
12164
12165 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12166 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12167
12168 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12169
12170 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12171 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12172
12173 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12174
12175 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12176 delete globalscripts[GLOBAL_SCRIPT_F6];
12177
12178 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12179
12180 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12181 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12182
12183 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12184 }
12185
12186
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 205 times.
384 if(s_version > 10) //expanded the number of Hero scripts to 5.
12187 {
12188
2/2
✓ Branch 0 taken 895 times.
✓ Branch 1 taken 179 times.
1074 for(int32_t i = 0; i < NUMSCRIPTHERO; i++)
12189 {
12190 895 ret = read_one_ffscript(f, Header, i, s_version, playerscripts[i], zmeta_version);
12191
12192
1/2
✓ Branch 0 taken 895 times.
✗ Branch 1 not taken.
895 if (ret)
12193 {
12194 return qe_invalid;
12195 }
12196 895 }
12197 179 }
12198 else
12199 {
12200
2/2
✓ Branch 0 taken 615 times.
✓ Branch 1 taken 205 times.
820 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12201 {
12202 615 ret = read_one_ffscript(f, Header, i, s_version, playerscripts[i], zmeta_version);
12203
12204
1/2
✓ Branch 0 taken 615 times.
✗ Branch 1 not taken.
615 if (ret)
12205 {
12206 return qe_invalid;
12207 }
12208 615 }
12209
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(playerscripts[3] != NULL)
12210
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 delete playerscripts[3];
12211
12212
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 playerscripts[3] = new script_data(ScriptType::Hero, 3);
12213
12214
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(playerscripts[4] != NULL)
12215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 delete playerscripts[4];
12216
12217
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 playerscripts[4] = new script_data(ScriptType::Hero, 4);
12218 }
12219
3/4
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 205 times.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
384 if(s_version > 8 && s_version < 10)
12220 {
12221
12222 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12223 {
12224 ret = read_one_ffscript(f, Header, i, s_version, ewpnscripts[i], zmeta_version);
12225
12226 if (ret)
12227 {
12228 return qe_invalid;
12229 }
12230 }
12231 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12232 {
12233 ret = read_one_ffscript(f, Header, i, s_version, dmapscripts[i], zmeta_version);
12234
12235 if (ret)
12236 {
12237 return qe_invalid;
12238 }
12239 }
12240
12241 }
12242
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 179 times.
384 if(s_version >= 10)
12243 {
12244
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 179 times.
46003 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12245 {
12246 45824 ret = read_one_ffscript(f, Header, i, s_version, lwpnscripts[i], zmeta_version);
12247
12248
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if (ret)
12249 {
12250 return qe_invalid;
12251 }
12252 45824 }
12253
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 179 times.
46003 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12254 {
12255 45824 ret = read_one_ffscript(f, Header, i, s_version, ewpnscripts[i], zmeta_version);
12256
12257
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if (ret)
12258 {
12259 return qe_invalid;
12260 }
12261 45824 }
12262
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 179 times.
46003 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12263 {
12264 45824 ret = read_one_ffscript(f, Header, i, s_version, dmapscripts[i], zmeta_version);
12265
12266
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if (ret)
12267 {
12268 return qe_invalid;
12269 }
12270 45824 }
12271
12272 179 }
12273
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 179 times.
384 if(s_version >=12)
12274 {
12275
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 179 times.
46003 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12276 {
12277 45824 ret = read_one_ffscript(f, Header, i, s_version, itemspritescripts[i], zmeta_version);
12278
12279
1/2
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
45824 if (ret)
12280 {
12281 return qe_invalid;
12282 }
12283 45824 }
12284 179 }
12285
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 179 times.
384 if(s_version >=15)
12286 {
12287
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 179 times.
91827 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12288 {
12289 91648 ret = read_one_ffscript(f, Header, i, s_version, comboscripts[i], zmeta_version);
12290
12291
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if (ret)
12292 {
12293 return qe_invalid;
12294 }
12295 91648 }
12296 179 }
12297
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 179 times.
384 if(s_version >19)
12298 {
12299 179 word numgenscripts = NUMSCRIPTSGENERIC;
12300
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(!p_igetw(&numgenscripts,f))
12301 {
12302 return qe_invalid;
12303 }
12304
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 179 times.
91827 for(int32_t i = 0; i < numgenscripts; i++)
12305 {
12306 91648 ret = read_one_ffscript(f, Header, i, s_version, genericscripts[i], zmeta_version);
12307
12308
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if (ret)
12309 {
12310 return qe_invalid;
12311 }
12312 91648 }
12313 179 }
12314
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 162 times.
384 if(s_version >21)
12315 {
12316 162 word numsubscripts = NUMSCRIPTSSUBSCREEN;
12317
1/2
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
162 if(!p_igetw(&numsubscripts,f))
12318 {
12319 return qe_invalid;
12320 }
12321
2/2
✓ Branch 0 taken 41472 times.
✓ Branch 1 taken 162 times.
41634 for(int32_t i = 0; i < numsubscripts; i++)
12322 {
12323 41472 ret = read_one_ffscript(f, Header, i, s_version, subscreenscripts[i], zmeta_version);
12324
12325
1/2
✓ Branch 0 taken 41472 times.
✗ Branch 1 not taken.
41472 if (ret)
12326 {
12327 return qe_invalid;
12328 }
12329 41472 }
12330 162 }
12331 384 }
12332
12333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(s_version > 2)
12334 {
12335 int32_t bufsize;
12336 384 p_igetl(&bufsize, f);
12337
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
384 if (bufsize < 0 || bufsize > 1024*1024*10)
12338 {
12339 // God help anyone storing more than 10MB of code in the script buffer.
12340 return qe_invalid;
12341 }
12342 384 char * buf = new char[bufsize+1];
12343 384 pfread(buf, bufsize, f);
12344 384 buf[bufsize]=0;
12345
12346
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 zScript = string(buf);
12347
12348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 delete[] buf;
12349 word numffcbindings;
12350 384 p_igetw(&numffcbindings, f);
12351
12352
2/2
✓ Branch 0 taken 10328 times.
✓ Branch 1 taken 384 times.
10712 for(int32_t i=0; i<numffcbindings; i++)
12353 {
12354 word id;
12355 10328 p_igetw(&id, f);
12356 10328 p_igetl(&bufsize, f);
12357
2/4
✓ Branch 0 taken 10328 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10328 times.
10328 if (bufsize < 0 || bufsize > 1024)
12358 return qe_invalid;
12359 10328 buf = new char[bufsize+1];
12360 10328 pfread(buf, bufsize, f);
12361 10328 buf[bufsize]=0;
12362
12363 //fix for buggy older saved quests -DD
12364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10328 times.
10328 if(id < NUMSCRIPTFFC-1)
12365 10328 ffcmap[id].scriptname = buf;
12366
12367
1/2
✓ Branch 0 taken 10328 times.
✗ Branch 1 not taken.
10328 delete[] buf;
12368 10328 }
12369
12370 word numglobalbindings;
12371 384 p_igetw(&numglobalbindings, f);
12372
12373
2/2
✓ Branch 0 taken 1573 times.
✓ Branch 1 taken 384 times.
1957 for(int32_t i=0; i<numglobalbindings; i++)
12374 {
12375 word id;
12376 1573 p_igetw(&id, f);
12377 1573 p_igetl(&bufsize, f);
12378
2/4
✓ Branch 0 taken 1573 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1573 times.
1573 if (bufsize < 0 || bufsize > 1024)
12379 return qe_invalid;
12380 1573 buf = new char[bufsize+1];
12381 1573 pfread(buf, bufsize, f);
12382 1573 buf[bufsize]=0;
12383
12384 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12385 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12386 // Ignore these. -DD
12387
2/2
✓ Branch 0 taken 558 times.
✓ Branch 1 taken 1015 times.
1573 if (id < NUMSCRIPTGLOBAL)
12388 {
12389 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12390
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 if(strcmp(buf,"~Continue") == 0)
12391 {
12392 globalmap[id].scriptname = "";
12393
12394 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12395 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12396 }
12397 else
12398 {
12399 1015 globalmap[id].scriptname = buf;
12400 }
12401 1015 }
12402
12403
1/2
✓ Branch 0 taken 1573 times.
✗ Branch 1 not taken.
1573 delete[] buf;
12404 1573 }
12405
12406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(s_version > 3)
12407 {
12408 word numitembindings;
12409 384 p_igetw(&numitembindings, f);
12410
12411
2/2
✓ Branch 0 taken 1297 times.
✓ Branch 1 taken 384 times.
1681 for(int32_t i=0; i<numitembindings; i++)
12412 {
12413 word id;
12414 1297 p_igetw(&id, f);
12415 1297 p_igetl(&bufsize, f);
12416
2/4
✓ Branch 0 taken 1297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1297 times.
✗ Branch 3 not taken.
1297 if (bufsize < 0 || bufsize > 1024)
12417 return qe_invalid;
12418 1297 buf = new char[bufsize+1];
12419 1297 pfread(buf, bufsize, f);
12420 1297 buf[bufsize]=0;
12421
12422 //fix this too
12423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1297 times.
1297 if(id <NUMSCRIPTITEM-1)
12424 1297 itemmap[id].scriptname = buf;
12425
12426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1297 times.
1297 delete[] buf;
12427 1297 }
12428 384 }
12429 //(v9+)
12430
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 179 times.
384 if(s_version > 8)
12431 {
12432 //npc scripts
12433 word numnpcbindings;
12434 179 p_igetw(&numnpcbindings, f);
12435
12436
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 179 times.
211 for(int32_t i=0; i<numnpcbindings; i++)
12437 {
12438 word id;
12439 32 p_igetw(&id, f);
12440 32 p_igetl(&bufsize, f);
12441
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 if (bufsize < 0 || bufsize > 1024)
12442 return qe_invalid;
12443 32 buf = new char[bufsize+1];
12444 32 pfread(buf, bufsize, f);
12445 32 buf[bufsize]=0;
12446
12447 //fix this too
12448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(id <NUMSCRIPTGUYS-1)
12449 32 npcmap[id].scriptname = buf;
12450
12451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 delete[] buf;
12452 32 }
12453 //lweapon
12454 word numlwpnbindings;
12455 179 p_igetw(&numlwpnbindings, f);
12456
12457
2/2
✓ Branch 0 taken 322 times.
✓ Branch 1 taken 179 times.
501 for(int32_t i=0; i<numlwpnbindings; i++)
12458 {
12459 word id;
12460 322 p_igetw(&id, f);
12461 322 p_igetl(&bufsize, f);
12462
2/4
✓ Branch 0 taken 322 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 322 times.
✗ Branch 3 not taken.
322 if (bufsize < 0 || bufsize > 1024)
12463 return qe_invalid;
12464 322 buf = new char[bufsize+1];
12465 322 pfread(buf, bufsize, f);
12466 322 buf[bufsize]=0;
12467
12468 //fix this too
12469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 if(id <NUMSCRIPTWEAPONS-1)
12470 322 lwpnmap[id].scriptname = buf;
12471
12472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 delete[] buf;
12473 322 }
12474 //eweapon
12475 word numewpnbindings;
12476 179 p_igetw(&numewpnbindings, f);
12477
12478
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 179 times.
476 for(int32_t i=0; i<numewpnbindings; i++)
12479 {
12480 word id;
12481 297 p_igetw(&id, f);
12482 297 p_igetl(&bufsize, f);
12483
2/4
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 297 times.
✗ Branch 3 not taken.
297 if (bufsize < 0 || bufsize > 1024)
12484 return qe_invalid;
12485 297 buf = new char[bufsize+1];
12486 297 pfread(buf, bufsize, f);
12487 297 buf[bufsize]=0;
12488
12489 //fix this too
12490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
297 if(id <NUMSCRIPTWEAPONS-1)
12491 297 ewpnmap[id].scriptname = buf;
12492
12493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
297 delete[] buf;
12494 297 }
12495 //hero
12496 word numherobindings;
12497 179 p_igetw(&numherobindings, f);
12498
12499
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 179 times.
202 for(int32_t i=0; i<numherobindings; i++)
12500 {
12501 word id;
12502 23 p_igetw(&id, f);
12503 23 p_igetl(&bufsize, f);
12504
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if (bufsize < 0 || bufsize > 1024)
12505 return qe_invalid;
12506 23 buf = new char[bufsize+1];
12507 23 pfread(buf, bufsize, f);
12508 23 buf[bufsize]=0;
12509
12510 //fix this too
12511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(id <NUMSCRIPTHERO-1)
12512 23 playermap[id].scriptname = buf;
12513
12514
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 delete[] buf;
12515 23 }
12516 //dmaps
12517 word numdmapbindings;
12518 179 p_igetw(&numdmapbindings, f);
12519
12520
2/2
✓ Branch 0 taken 406 times.
✓ Branch 1 taken 179 times.
585 for(int32_t i=0; i<numdmapbindings; i++)
12521 {
12522 word id;
12523 406 p_igetw(&id, f);
12524 406 p_igetl(&bufsize, f);
12525
2/4
✓ Branch 0 taken 406 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 406 times.
✗ Branch 3 not taken.
406 if (bufsize < 0 || bufsize > 1024)
12526 return qe_invalid;
12527 406 buf = new char[bufsize+1];
12528 406 pfread(buf, bufsize, f);
12529 406 buf[bufsize]=0;
12530
12531 //fix this too
12532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
406 if(id <NUMSCRIPTSDMAP-1)
12533 406 dmapmap[id].scriptname = buf;
12534
12535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
406 delete[] buf;
12536 406 }
12537 //screen
12538 word numscreenbindings;
12539 179 p_igetw(&numscreenbindings, f);
12540
12541
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 179 times.
582 for(int32_t i=0; i<numscreenbindings; i++)
12542 {
12543 word id;
12544 403 p_igetw(&id, f);
12545 403 p_igetl(&bufsize, f);
12546
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if (bufsize < 0 || bufsize > 1024)
12547 return qe_invalid;
12548 403 buf = new char[bufsize+1];
12549 403 pfread(buf, bufsize, f);
12550 403 buf[bufsize]=0;
12551
12552 //fix this too
12553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 403 times.
403 if(id <NUMSCRIPTSDMAP-1)
12554 403 screenmap[id].scriptname = buf;
12555
12556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 403 times.
403 delete[] buf;
12557 403 }
12558 179 }
12559
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 179 times.
384 if(s_version > 11)
12560 {
12561 word numspritebindings;
12562 179 p_igetw(&numspritebindings, f);
12563
12564
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 179 times.
228 for(int32_t i=0; i<numspritebindings; i++)
12565 {
12566 word id;
12567 49 p_igetw(&id, f);
12568 49 p_igetl(&bufsize, f);
12569
2/4
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
49 if (bufsize < 0 || bufsize > 1024)
12570 return qe_invalid;
12571 49 buf = new char[bufsize+1];
12572 49 pfread(buf, bufsize, f);
12573 49 buf[bufsize]=0;
12574
12575 //fix this too
12576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 if(id <NUMSCRIPTSDMAP-1)
12577 49 itemspritemap[id].scriptname = buf;
12578
12579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 delete[] buf;
12580 49 }
12581 179 }
12582
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 179 times.
384 if(s_version >= 15)
12583 {
12584 word numcombobindings;
12585 179 p_igetw(&numcombobindings, f);
12586
12587
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 179 times.
336 for(int32_t i=0; i<numcombobindings; i++)
12588 {
12589 word id;
12590 157 p_igetw(&id, f);
12591 157 p_igetl(&bufsize, f);
12592
2/4
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 157 times.
157 if (bufsize < 0 || bufsize > 1024)
12593 return qe_invalid;
12594 157 buf = new char[bufsize+1];
12595 157 pfread(buf, bufsize, f);
12596 157 buf[bufsize]=0;
12597
12598 //fix this too
12599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157 times.
157 if(id <NUMSCRIPTSCOMBODATA-1)
12600 157 comboscriptmap[id].scriptname = buf;
12601
12602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157 times.
157 delete[] buf;
12603 157 }
12604 179 }
12605
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 179 times.
384 if(s_version > 19)
12606 {
12607 word numgenericbindings;
12608 179 p_igetw(&numgenericbindings, f);
12609
12610
2/2
✓ Branch 0 taken 1513 times.
✓ Branch 1 taken 179 times.
1692 for(int32_t i=0; i<numgenericbindings; i++)
12611 {
12612 word id;
12613 1513 p_igetw(&id, f);
12614 1513 p_igetl(&bufsize, f);
12615
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if (bufsize < 0 || bufsize > 1024)
12616 return qe_invalid;
12617 1513 buf = new char[bufsize+1];
12618 1513 pfread(buf, bufsize, f);
12619 1513 buf[bufsize]=0;
12620
12621 //fix this too
12622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1513 times.
1513 if(id <NUMSCRIPTSGENERIC-1)
12623 1513 genericmap[id].scriptname = buf;
12624
12625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1513 times.
1513 delete[] buf;
12626 1513 }
12627 179 }
12628
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 162 times.
384 if(s_version > 21)
12629 {
12630 word numsubscreenbindings;
12631 162 p_igetw(&numsubscreenbindings, f);
12632
12633
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 162 times.
170 for(int32_t i=0; i<numsubscreenbindings; i++)
12634 {
12635 word id;
12636 8 p_igetw(&id, f);
12637 8 p_igetl(&bufsize, f);
12638
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if (bufsize < 0 || bufsize > 1024)
12639 return qe_invalid;
12640 8 buf = new char[bufsize+1];
12641 8 pfread(buf, bufsize, f);
12642 8 buf[bufsize]=0;
12643
12644 //fix this too
12645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(id <NUMSCRIPTSSUBSCREEN-1)
12646 8 subscreenmap[id].scriptname = buf;
12647
12648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 delete[] buf;
12649 8 }
12650 162 }
12651 384 }
12652
12653 // Set ZScriptVersion to the value encoded in the script's meta.ffscript_v.
12654 // This is only updated when the scripts have been recompiled.
12655 // They should all match each other.
12656 384 std::optional<word> zscript_version;
12657
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 179 times.
384 if (s_version >= 16)
12658 {
12659
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 6285 times.
6462 for (auto script : read_scripts)
12660 {
12661
2/2
✓ Branch 0 taken 6283 times.
✓ Branch 1 taken 2 times.
6285 if (script->meta.ffscript_v == 0)
12662 {
12663 // These scripts were saved in a version prior to this field being set.
12664 // See https://discord.com/channels/876899628556091432/1368485306394738718
12665 2 zscript_version = 16;
12666 2 break;
12667 }
12668
1/2
✓ Branch 0 taken 6283 times.
✗ Branch 1 not taken.
6283 if (script->meta.ffscript_v > s_version)
12669 break;
12670
12671
2/2
✓ Branch 0 taken 6123 times.
✓ Branch 1 taken 160 times.
6283 if (!zscript_version.has_value())
12672 {
12673 160 zscript_version = script->meta.ffscript_v;
12674 160 continue;
12675 }
12676
12677
1/2
✓ Branch 0 taken 6123 times.
✗ Branch 1 not taken.
6123 if (zscript_version.value() != script->meta.ffscript_v)
12678 {
12679 zscript_version.reset();
12680 break;
12681 }
12682 }
12683
12684
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 17 times.
179 if (!zscript_version.has_value())
12685 17 al_trace("WARNING: Setting zscript version to section version as fallback.\n");
12686 179 }
12687 384 setZScriptVersion(zscript_version.value_or(s_version));
12688 384 read_scripts.clear();
12689
12690 384 return 0;
12691 384 }
12692
12693 void(*reset_scripts_hook)();
12694
12695 466 void reset_scripts()
12696 {
12697 // We can't modify the script data while jit threads are possibly compiling them.
12698
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 455 times.
466 if (reset_scripts_hook)
12699 455 reset_scripts_hook();
12700
12701
2/2
✓ Branch 0 taken 238592 times.
✓ Branch 1 taken 466 times.
239058 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12702 {
12703
1/2
✓ Branch 0 taken 238592 times.
✗ Branch 1 not taken.
238592 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12704 else genericscripts[i] = new script_data({ScriptType::Generic, i});
12705 238592 }
12706
12707
2/2
✓ Branch 0 taken 238592 times.
✓ Branch 1 taken 466 times.
239058 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12708 {
12709
1/2
✓ Branch 0 taken 238592 times.
✗ Branch 1 not taken.
238592 if (ffscripts[i])
12710 238592 ffscripts[i]->disable();
12711 else
12712 ffscripts[i] = new script_data(ScriptType::FFC, i);
12713 238592 }
12714
12715
2/2
✓ Branch 0 taken 119296 times.
✓ Branch 1 taken 466 times.
119762 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12716 {
12717
1/2
✓ Branch 0 taken 119296 times.
✗ Branch 1 not taken.
119296 if (itemscripts[i])
12718 119296 itemscripts[i]->disable();
12719 else
12720 itemscripts[i] = new script_data(ScriptType::Item, i);
12721 119296 }
12722
12723
2/2
✓ Branch 0 taken 119296 times.
✓ Branch 1 taken 466 times.
119762 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12724 {
12725
1/2
✓ Branch 0 taken 119296 times.
✗ Branch 1 not taken.
119296 if (guyscripts[i])
12726 119296 guyscripts[i]->disable();
12727 else
12728 guyscripts[i] = new script_data(ScriptType::NPC, i);
12729 119296 }
12730
12731
2/2
✓ Branch 0 taken 119296 times.
✓ Branch 1 taken 466 times.
119762 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12732 {
12733
1/2
✓ Branch 0 taken 119296 times.
✗ Branch 1 not taken.
119296 if (screenscripts[i])
12734 119296 screenscripts[i]->disable();
12735 else
12736 screenscripts[i] = new script_data(ScriptType::Screen, i);
12737 119296 }
12738
12739
2/2
✓ Branch 0 taken 3728 times.
✓ Branch 1 taken 466 times.
4194 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12740 {
12741
1/2
✓ Branch 0 taken 3728 times.
✗ Branch 1 not taken.
3728 if (globalscripts[i])
12742 3728 globalscripts[i]->disable();
12743 else
12744 globalscripts[i] = new script_data(ScriptType::Global, i);
12745 3728 }
12746
12747
2/2
✓ Branch 0 taken 2330 times.
✓ Branch 1 taken 466 times.
2796 for(int32_t i=0; i<NUMSCRIPTHERO; i++)
12748 {
12749
1/2
✓ Branch 0 taken 2330 times.
✗ Branch 1 not taken.
2330 if (playerscripts[i])
12750 2330 playerscripts[i]->disable();
12751 else
12752 playerscripts[i] = new script_data(ScriptType::Hero, i);
12753 2330 }
12754
12755
2/2
✓ Branch 0 taken 119296 times.
✓ Branch 1 taken 466 times.
119762 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12756 {
12757
1/2
✓ Branch 0 taken 119296 times.
✗ Branch 1 not taken.
119296 if (lwpnscripts[i])
12758 119296 lwpnscripts[i]->disable();
12759 else
12760 lwpnscripts[i] = new script_data(ScriptType::Lwpn, i);
12761 119296 }
12762
2/2
✓ Branch 0 taken 119296 times.
✓ Branch 1 taken 466 times.
119762 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12763 {
12764
1/2
✓ Branch 0 taken 119296 times.
✗ Branch 1 not taken.
119296 if (ewpnscripts[i])
12765 119296 ewpnscripts[i]->disable();
12766 else
12767 ewpnscripts[i] = new script_data(ScriptType::Ewpn, i);
12768 119296 }
12769
12770
2/2
✓ Branch 0 taken 119296 times.
✓ Branch 1 taken 466 times.
119762 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12771 {
12772
1/2
✓ Branch 0 taken 119296 times.
✗ Branch 1 not taken.
119296 if (dmapscripts[i])
12773 119296 dmapscripts[i]->disable();
12774 else
12775 dmapscripts[i] = new script_data(ScriptType::DMap, i);
12776 119296 }
12777
2/2
✓ Branch 0 taken 119296 times.
✓ Branch 1 taken 466 times.
119762 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12778 {
12779
1/2
✓ Branch 0 taken 119296 times.
✗ Branch 1 not taken.
119296 if (itemspritescripts[i])
12780 119296 itemspritescripts[i]->disable();
12781 else
12782 itemspritescripts[i] = new script_data(ScriptType::ItemSprite, i);
12783 119296 }
12784
2/2
✓ Branch 0 taken 238592 times.
✓ Branch 1 taken 466 times.
239058 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12785 {
12786
1/2
✓ Branch 0 taken 238592 times.
✗ Branch 1 not taken.
238592 if (comboscripts[i])
12787 238592 comboscripts[i]->disable();
12788 else
12789 comboscripts[i] = new script_data(ScriptType::Combo, i);
12790 238592 }
12791
2/2
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 119296 times.
119762 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
12792 {
12793
1/2
✓ Branch 0 taken 119296 times.
✗ Branch 1 not taken.
119296 if (subscreenscripts[i])
12794 119296 subscreenscripts[i]->disable();
12795 else
12796 subscreenscripts[i] = new script_data(ScriptType::EngineSubscreen, i);
12797 119296 }
12798 466 }
12799
12800 // 3.0+ calls this.
12801 114 int32_t read_quest_zasm(PACKFILE *f, word s_version)
12802 {
12803 int32_t num_commands;
12804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!p_igetl(&num_commands,f))
12805 return qe_invalid;
12806 #ifdef ZC_FUZZ
12807 const int32_t command_limit = 300000;
12808 #else
12809 114 const int32_t command_limit = 25000000;
12810 #endif
12811
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 if (num_commands < 0 || num_commands > command_limit)
12812 return qe_invalid;
12813
12814 114 std::vector<ffscript> zasm;
12815
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 zasm.reserve(num_commands);
12816
2/2
✓ Branch 0 taken 2742605 times.
✓ Branch 1 taken 114 times.
2742719 for(int32_t j=0; j<num_commands; j++)
12817 {
12818
1/2
✓ Branch 0 taken 2742605 times.
✗ Branch 1 not taken.
2742605 ffscript temp_script;
12819
2/4
✓ Branch 0 taken 2742605 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2742605 times.
✗ Branch 3 not taken.
2742605 if(!p_igetw(&(temp_script.command),f))
12820 return qe_invalid;
12821
12822
2/4
✓ Branch 0 taken 2742605 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2742605 times.
✗ Branch 3 not taken.
2742605 if(!p_igetl(&(temp_script.arg1),f))
12823 return qe_invalid;
12824
12825
2/4
✓ Branch 0 taken 2742605 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2742605 times.
✗ Branch 3 not taken.
2742605 if(!p_igetl(&(temp_script.arg2),f))
12826 return qe_invalid;
12827
12828
2/4
✓ Branch 0 taken 2742605 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2742605 times.
✗ Branch 3 not taken.
2742605 if(!p_igetl(&(temp_script.arg3),f))
12829 return qe_invalid;
12830
12831 2742605 uint32_t sz = 0;
12832
2/4
✓ Branch 0 taken 2742605 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2742605 times.
✗ Branch 3 not taken.
2742605 if(!p_igetl(&sz,f))
12833 return qe_invalid;
12834
2/2
✓ Branch 0 taken 23317 times.
✓ Branch 1 taken 2719288 times.
2742605 if(sz) //string found
12835 {
12836
1/2
✓ Branch 0 taken 23317 times.
✗ Branch 1 not taken.
23317 temp_script.strptr = new std::string();
12837 char dummy;
12838
2/2
✓ Branch 0 taken 393860 times.
✓ Branch 1 taken 23317 times.
417177 for(size_t q = 0; q < sz; ++q)
12839 {
12840
2/4
✓ Branch 0 taken 393860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 393860 times.
✗ Branch 3 not taken.
393860 if(!p_getc(&dummy,f))
12841 return qe_invalid;
12842
1/2
✓ Branch 0 taken 393860 times.
✗ Branch 1 not taken.
393860 temp_script.strptr->push_back(dummy);
12843 393860 }
12844 23317 }
12845
2/4
✓ Branch 0 taken 2742605 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2742605 times.
✗ Branch 3 not taken.
2742605 if(!p_igetl(&sz,f))
12846 return qe_invalid;
12847
2/2
✓ Branch 0 taken 3387 times.
✓ Branch 1 taken 2739218 times.
2742605 if(sz) //vector found
12848 {
12849
1/2
✓ Branch 0 taken 3387 times.
✗ Branch 1 not taken.
3387 temp_script.vecptr = new std::vector<int32_t>();
12850 int32_t dummy;
12851
2/2
✓ Branch 0 taken 11136 times.
✓ Branch 1 taken 3387 times.
14523 for(size_t q = 0; q < sz; ++q)
12852 {
12853
2/4
✓ Branch 0 taken 11136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11136 times.
✗ Branch 3 not taken.
11136 if(!p_igetl(&dummy,f))
12854 return qe_invalid;
12855
1/2
✓ Branch 0 taken 11136 times.
✗ Branch 1 not taken.
11136 temp_script.vecptr->push_back(dummy);
12856 11136 }
12857 3387 }
12858
1/2
✓ Branch 0 taken 2742605 times.
✗ Branch 1 not taken.
2742605 zasm.emplace_back(std::move(temp_script));
12859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2742605 times.
2742605 }
12860
12861
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 assert(zasm_scripts.empty());
12862 114 zasm_script_id id = zasm_scripts.size();
12863
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, "@single", std::move(zasm)));
12864
12865 114 return 0;
12866 114 }
12867
12868 1001650 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, script_data *script, word zmeta_version)
12869 {
12870 ASSERT(script);
12871
2/2
✓ Branch 0 taken 562408 times.
✓ Branch 1 taken 439242 times.
1001650 if(s_version < 27)
12872 562408 return read_old_ffscript(f, script_index, s_version, script, zmeta_version);
12873
12874 char exists;
12875
1/2
✓ Branch 0 taken 439242 times.
✗ Branch 1 not taken.
439242 if (!p_getc(&exists, f))
12876 return qe_invalid;
12877
2/2
✓ Branch 0 taken 3247 times.
✓ Branch 1 taken 435995 times.
439242 if (!exists)
12878 {
12879 435995 script->disable();
12880 435995 return 0;
12881 }
12882
12883 //Read meta
12884 {
12885 3247 zasm_meta temp_meta;
12886
12887
2/4
✓ Branch 0 taken 3247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3247 times.
✗ Branch 3 not taken.
3247 if(!p_igetw(&(temp_meta.zasm_v),f))
12888 return qe_invalid;
12889
2/4
✓ Branch 0 taken 3247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3247 times.
✗ Branch 3 not taken.
3247 if(!p_igetw(&(temp_meta.meta_v),f))
12890 return qe_invalid;
12891
2/4
✓ Branch 0 taken 3247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3247 times.
✗ Branch 3 not taken.
3247 if(!p_igetw(&(temp_meta.ffscript_v),f))
12892 return qe_invalid;
12893
2/4
✓ Branch 0 taken 3247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3247 times.
✗ Branch 3 not taken.
3247 if(!p_getc(&(temp_meta.script_type),f))
12894 return qe_invalid;
12895
12896
2/2
✓ Branch 0 taken 25976 times.
✓ Branch 1 taken 3247 times.
29223 for(int32_t q = 0; q < 8; ++q)
12897 {
12898
2/4
✓ Branch 0 taken 25976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25976 times.
✗ Branch 3 not taken.
25976 if(!p_getcstr(&temp_meta.run_idens[q],f))
12899 return qe_invalid;
12900 25976 }
12901
12902
2/2
✓ Branch 0 taken 3247 times.
✓ Branch 1 taken 25976 times.
29223 for(int32_t q = 0; q < 8; ++q)
12903
2/4
✓ Branch 0 taken 25976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25976 times.
✗ Branch 3 not taken.
25976 if(!p_getc(&(temp_meta.run_types[q]),f))
12904 return qe_invalid;
12905
12906
2/4
✓ Branch 0 taken 3247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3247 times.
✗ Branch 3 not taken.
3247 if(!p_getc(&(temp_meta.flags),f))
12907 return qe_invalid;
12908
12909
2/4
✓ Branch 0 taken 3247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3247 times.
✗ Branch 3 not taken.
3247 if(!p_igetw(&(temp_meta.compiler_v1),f))
12910 return qe_invalid;
12911
2/4
✓ Branch 0 taken 3247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3247 times.
✗ Branch 3 not taken.
3247 if(!p_igetw(&(temp_meta.compiler_v2),f))
12912 return qe_invalid;
12913
2/4
✓ Branch 0 taken 3247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3247 times.
✗ Branch 3 not taken.
3247 if(!p_igetw(&(temp_meta.compiler_v3),f))
12914 return qe_invalid;
12915
2/4
✓ Branch 0 taken 3247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3247 times.
✗ Branch 3 not taken.
3247 if(!p_igetw(&(temp_meta.compiler_v4),f))
12916 return qe_invalid;
12917
12918
2/4
✓ Branch 0 taken 3247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3247 times.
✗ Branch 3 not taken.
3247 if(!p_getcstr(&temp_meta.script_name,f))
12919 return qe_invalid;
12920
2/4
✓ Branch 0 taken 3247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3247 times.
✗ Branch 3 not taken.
3247 if(!p_getcstr(&temp_meta.author,f))
12921 return qe_invalid;
12922 3247 auto num_meta_attrib = 10;
12923
2/2
✓ Branch 0 taken 32470 times.
✓ Branch 1 taken 3247 times.
35717 for(auto q = 0; q < num_meta_attrib; ++q)
12924 {
12925
2/4
✓ Branch 0 taken 32470 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32470 times.
✗ Branch 3 not taken.
32470 if(!p_getcstr(&temp_meta.attributes[q],f))
12926 return qe_invalid;
12927
2/4
✓ Branch 0 taken 32470 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32470 times.
✗ Branch 3 not taken.
32470 if(!p_getwstr(&temp_meta.attributes_help[q],f))
12928 return qe_invalid;
12929 32470 }
12930
2/2
✓ Branch 0 taken 25976 times.
✓ Branch 1 taken 3247 times.
29223 for(auto q = 0; q < 8; ++q)
12931 {
12932
2/4
✓ Branch 0 taken 25976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25976 times.
✗ Branch 3 not taken.
25976 if(!p_getcstr(&temp_meta.attribytes[q],f))
12933 return qe_invalid;
12934
2/4
✓ Branch 0 taken 25976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25976 times.
✗ Branch 3 not taken.
25976 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
12935 return qe_invalid;
12936 25976 }
12937
2/2
✓ Branch 0 taken 25976 times.
✓ Branch 1 taken 3247 times.
29223 for(auto q = 0; q < 8; ++q)
12938 {
12939
2/4
✓ Branch 0 taken 25976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25976 times.
✗ Branch 3 not taken.
25976 if(!p_getcstr(&temp_meta.attrishorts[q],f))
12940 return qe_invalid;
12941
2/4
✓ Branch 0 taken 25976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25976 times.
✗ Branch 3 not taken.
25976 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
12942 return qe_invalid;
12943 25976 }
12944
2/2
✓ Branch 0 taken 51952 times.
✓ Branch 1 taken 3247 times.
55199 for(auto q = 0; q < 16; ++q)
12945 {
12946
2/4
✓ Branch 0 taken 51952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51952 times.
✗ Branch 3 not taken.
51952 if(!p_getcstr(&temp_meta.usrflags[q],f))
12947 return qe_invalid;
12948
2/4
✓ Branch 0 taken 51952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51952 times.
✗ Branch 3 not taken.
51952 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
12949 return qe_invalid;
12950 51952 }
12951
2/2
✓ Branch 0 taken 25976 times.
✓ Branch 1 taken 3247 times.
29223 for(auto q = 0; q < 8; ++q)
12952 {
12953
2/4
✓ Branch 0 taken 25976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25976 times.
✗ Branch 3 not taken.
25976 if(!p_getcstr(&temp_meta.initd[q],f))
12954 return qe_invalid;
12955
2/4
✓ Branch 0 taken 25976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25976 times.
✗ Branch 3 not taken.
25976 if(!p_getwstr(&temp_meta.initd_help[q],f))
12956 return qe_invalid;
12957 25976 }
12958
2/2
✓ Branch 0 taken 3247 times.
✓ Branch 1 taken 25976 times.
29223 for(auto q = 0; q < 8; ++q)
12959 {
12960
2/4
✓ Branch 0 taken 25976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25976 times.
✗ Branch 3 not taken.
25976 if(!p_getc(&temp_meta.initd_type[q],f))
12961 return qe_invalid;
12962 25976 }
12963
12964
1/2
✓ Branch 0 taken 3247 times.
✗ Branch 1 not taken.
3247 script->meta = temp_meta;
12965
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3247 times.
3247 }
12966
1/2
✓ Branch 0 taken 3247 times.
✗ Branch 1 not taken.
3247 if(!p_igetl(&script->pc, f))
12967 return qe_invalid;
12968
1/2
✓ Branch 0 taken 3247 times.
✗ Branch 1 not taken.
3247 if(!p_igetl(&script->end_pc, f))
12969 return qe_invalid;
12970
12971
1/2
✓ Branch 0 taken 3247 times.
✗ Branch 1 not taken.
3247 assert(zasm_scripts.size() == 1);
12972 3247 auto& zs = zasm_scripts[0];
12973 3247 script->zasm_script = zs;
12974
12975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3247 times.
3247 if (script->valid())
12976 {
12977 3247 zs->script_datas.push_back(script);
12978 3247 read_scripts.push_back(script);
12979 3247 }
12980
12981 3247 return 0;
12982 1001650 }
12983
12984 562408 int32_t read_old_ffscript(PACKFILE *f, int32_t script_index, word s_version, script_data *script, word zmeta_version)
12985 {
12986 562408 char b33[34] = {0};
12987 562408 b33[33] = 0;
12988 562408 int32_t num_commands=1000;
12989
12990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 562408 times.
562408 if(s_version>=2)
12991 {
12992
1/2
✓ Branch 0 taken 562408 times.
✗ Branch 1 not taken.
562408 if(!p_igetl(&num_commands,f))
12993 {
12994 return qe_invalid;
12995 }
12996 562408 }
12997
12998 #ifdef ZC_FUZZ
12999 const int32_t command_limit = 300000;
13000 #else
13001 562408 const int32_t command_limit = 10000000;
13002 #endif
13003
2/4
✓ Branch 0 taken 562408 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 562408 times.
562408 if (num_commands < 0 || num_commands > command_limit)
13004 {
13005 return qe_invalid;
13006 }
13007
13008 562408 std::vector<ffscript> zasm;
13009
1/2
✓ Branch 0 taken 562408 times.
✗ Branch 1 not taken.
562408 zasm.reserve(num_commands);
13010
13011
2/2
✓ Branch 0 taken 246093 times.
✓ Branch 1 taken 316315 times.
562408 if(s_version >= 16)
13012 {
13013
1/2
✓ Branch 0 taken 246093 times.
✗ Branch 1 not taken.
246093 zasm_meta temp_meta;
13014
13015
2/4
✓ Branch 0 taken 246093 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246093 times.
✗ Branch 3 not taken.
246093 if(!p_igetw(&(temp_meta.zasm_v),f))
13016 {
13017 return qe_invalid;
13018 }
13019
13020
2/4
✓ Branch 0 taken 246093 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246093 times.
✗ Branch 3 not taken.
246093 if(!p_igetw(&(temp_meta.meta_v),f))
13021 {
13022 return qe_invalid;
13023 }
13024
13025
2/4
✓ Branch 0 taken 246093 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246093 times.
✗ Branch 3 not taken.
246093 if(!p_igetw(&(temp_meta.ffscript_v),f))
13026 {
13027 return qe_invalid;
13028 }
13029
13030
2/4
✓ Branch 0 taken 246093 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246093 times.
✗ Branch 3 not taken.
246093 if(!p_getc(&(temp_meta.script_type),f))
13031 {
13032 return qe_invalid;
13033 }
13034
13035
2/2
✓ Branch 0 taken 1968744 times.
✓ Branch 1 taken 246093 times.
2214837 for(int32_t q = 0; q < 8; ++q)
13036 {
13037
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 1824864 times.
1968744 if(zmeta_version < 3)
13038 {
13039
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 4748040 times.
4891920 for(int32_t c = 0; c < 33; ++c)
13040 {
13041
2/4
✓ Branch 0 taken 4748040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4748040 times.
✗ Branch 3 not taken.
4748040 if(!p_getc(&(b33[c]),f))
13042 {
13043 return qe_invalid;
13044 }
13045 4748040 }
13046
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.run_idens[q].assign(b33);
13047 143880 }
13048 else
13049 {
13050
2/4
✓ Branch 0 taken 1824864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1824864 times.
✗ Branch 3 not taken.
1824864 if(!p_getcstr(&temp_meta.run_idens[q],f))
13051 {
13052 return qe_invalid;
13053 }
13054 }
13055 1968744 }
13056
13057
2/2
✓ Branch 0 taken 246093 times.
✓ Branch 1 taken 1968744 times.
2214837 for(int32_t q = 0; q < 8; ++q)
13058 {
13059
2/4
✓ Branch 0 taken 1968744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1968744 times.
✗ Branch 3 not taken.
1968744 if(!p_getc(&(temp_meta.run_types[q]),f))
13060 {
13061 return qe_invalid;
13062 }
13063 1968744 }
13064
13065
2/4
✓ Branch 0 taken 246093 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246093 times.
✗ Branch 3 not taken.
246093 if(!p_getc(&(temp_meta.flags),f))
13066 {
13067 return qe_invalid;
13068 }
13069
13070
2/4
✓ Branch 0 taken 246093 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246093 times.
✗ Branch 3 not taken.
246093 if(!p_igetw(&(temp_meta.compiler_v1),f))
13071 {
13072 return qe_invalid;
13073 }
13074
13075
2/4
✓ Branch 0 taken 246093 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246093 times.
✗ Branch 3 not taken.
246093 if(!p_igetw(&(temp_meta.compiler_v2),f))
13076 {
13077 return qe_invalid;
13078 }
13079
13080
2/4
✓ Branch 0 taken 246093 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246093 times.
✗ Branch 3 not taken.
246093 if(!p_igetw(&(temp_meta.compiler_v3),f))
13081 {
13082 return qe_invalid;
13083 }
13084
13085
2/4
✓ Branch 0 taken 246093 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246093 times.
✗ Branch 3 not taken.
246093 if(!p_igetw(&(temp_meta.compiler_v4),f))
13086 {
13087 return qe_invalid;
13088 }
13089
13090
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 228108 times.
246093 if(zmeta_version == 2)
13091 {
13092
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
13093 {
13094
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
13095 {
13096 return qe_invalid;
13097 }
13098 593505 }
13099
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.script_name.assign(b33);
13100
13101
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
13102 {
13103
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
13104 {
13105 return qe_invalid;
13106 }
13107 593505 }
13108
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.author.assign(b33);
13109 17985 }
13110
1/2
✓ Branch 0 taken 228108 times.
✗ Branch 1 not taken.
228108 else if(zmeta_version > 2)
13111 {
13112
2/4
✓ Branch 0 taken 228108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 228108 times.
✗ Branch 3 not taken.
228108 if(!p_getcstr(&temp_meta.script_name,f))
13113 return qe_invalid;
13114
2/4
✓ Branch 0 taken 228108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 228108 times.
✗ Branch 3 not taken.
228108 if(!p_getcstr(&temp_meta.author,f))
13115 return qe_invalid;
13116 228108 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13117
2/2
✓ Branch 0 taken 2281080 times.
✓ Branch 1 taken 228108 times.
2509188 for(auto q = 0; q < num_meta_attrib; ++q)
13118 {
13119
2/4
✓ Branch 0 taken 2281080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2281080 times.
✗ Branch 3 not taken.
2281080 if(!p_getcstr(&temp_meta.attributes[q],f))
13120 return qe_invalid;
13121
2/4
✓ Branch 0 taken 2281080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2281080 times.
✗ Branch 3 not taken.
2281080 if(!p_getwstr(&temp_meta.attributes_help[q],f))
13122 return qe_invalid;
13123 2281080 }
13124
2/2
✓ Branch 0 taken 1824864 times.
✓ Branch 1 taken 228108 times.
2052972 for(auto q = 0; q < 8; ++q)
13125 {
13126
2/4
✓ Branch 0 taken 1824864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1824864 times.
✗ Branch 3 not taken.
1824864 if(!p_getcstr(&temp_meta.attribytes[q],f))
13127 return qe_invalid;
13128
2/4
✓ Branch 0 taken 1824864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1824864 times.
✗ Branch 3 not taken.
1824864 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
13129 return qe_invalid;
13130 1824864 }
13131
2/2
✓ Branch 0 taken 1824864 times.
✓ Branch 1 taken 228108 times.
2052972 for(auto q = 0; q < 8; ++q)
13132 {
13133
2/4
✓ Branch 0 taken 1824864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1824864 times.
✗ Branch 3 not taken.
1824864 if(!p_getcstr(&temp_meta.attrishorts[q],f))
13134 return qe_invalid;
13135
2/4
✓ Branch 0 taken 1824864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1824864 times.
✗ Branch 3 not taken.
1824864 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
13136 return qe_invalid;
13137 1824864 }
13138
2/2
✓ Branch 0 taken 3649728 times.
✓ Branch 1 taken 228108 times.
3877836 for(auto q = 0; q < 16; ++q)
13139 {
13140
2/4
✓ Branch 0 taken 3649728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3649728 times.
✗ Branch 3 not taken.
3649728 if(!p_getcstr(&temp_meta.usrflags[q],f))
13141 return qe_invalid;
13142
2/4
✓ Branch 0 taken 3649728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3649728 times.
✗ Branch 3 not taken.
3649728 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
13143 return qe_invalid;
13144 3649728 }
13145 228108 }
13146
2/2
✓ Branch 0 taken 228108 times.
✓ Branch 1 taken 17985 times.
246093 if(zmeta_version > 3)
13147 {
13148
2/2
✓ Branch 0 taken 1824864 times.
✓ Branch 1 taken 228108 times.
2052972 for(auto q = 0; q < 8; ++q)
13149 {
13150
2/4
✓ Branch 0 taken 1824864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1824864 times.
✗ Branch 3 not taken.
1824864 if(!p_getcstr(&temp_meta.initd[q],f))
13151 return qe_invalid;
13152
2/4
✓ Branch 0 taken 1824864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1824864 times.
✗ Branch 3 not taken.
1824864 if(!p_getwstr(&temp_meta.initd_help[q],f))
13153 return qe_invalid;
13154 1824864 }
13155
2/2
✓ Branch 0 taken 1824864 times.
✓ Branch 1 taken 228108 times.
2052972 for(auto q = 0; q < 8; ++q)
13156 {
13157
2/4
✓ Branch 0 taken 1824864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1824864 times.
✗ Branch 3 not taken.
1824864 if(!p_getc(&temp_meta.initd_type[q],f))
13158 return qe_invalid;
13159 1824864 }
13160 228108 }
13161 else
13162 {
13163
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 17985 times.
161865 for(auto q = 0; q < 8; ++q)
13164 {
13165
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.initd[q] = temp_meta.run_idens[q];
13166 143880 }
13167 }
13168
13169
1/2
✓ Branch 0 taken 246093 times.
✗ Branch 1 not taken.
246093 script->meta = temp_meta;
13170
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 246093 times.
✓ Branch 2 taken 316315 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 316315 times.
✗ Branch 5 not taken.
562408 } else script->meta = {};
13171
13172
2/2
✓ Branch 0 taken 107363499 times.
✓ Branch 1 taken 70839 times.
107434338 for(int32_t j=0; j<num_commands; j++)
13173 {
13174
1/2
✓ Branch 0 taken 107363499 times.
✗ Branch 1 not taken.
107363499 auto& sc = zasm.emplace_back();
13175
2/4
✓ Branch 0 taken 107363499 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107363499 times.
✗ Branch 3 not taken.
107363499 if(!p_igetw(&sc.command,f))
13176 {
13177 return qe_invalid;
13178 }
13179
13180
2/2
✓ Branch 0 taken 106871930 times.
✓ Branch 1 taken 491569 times.
107363499 if(sc.command == 0xFFFF)
13181 491569 break;
13182 else
13183 {
13184
2/4
✓ Branch 0 taken 106871930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106871930 times.
✗ Branch 3 not taken.
106871930 if(!p_igetl(&sc.arg1,f))
13185 {
13186 return qe_invalid;
13187 }
13188
13189
2/4
✓ Branch 0 taken 106871930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106871930 times.
✗ Branch 3 not taken.
106871930 if(!p_igetl(&sc.arg2,f))
13190 {
13191 return qe_invalid;
13192 }
13193
13194
2/2
✓ Branch 0 taken 1046346 times.
✓ Branch 1 taken 105825584 times.
106871930 if(s_version >= 24)
13195
2/4
✓ Branch 0 taken 1046346 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1046346 times.
✗ Branch 3 not taken.
1046346 if(!p_igetl(&sc.arg3,f))
13196 return qe_invalid;
13197
13198
2/2
✓ Branch 0 taken 8220636 times.
✓ Branch 1 taken 98651294 times.
106871930 if(s_version >= 21)
13199 {
13200 8220636 uint32_t sz = 0;
13201
2/4
✓ Branch 0 taken 8220636 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8220636 times.
✗ Branch 3 not taken.
8220636 if(!p_igetl(&sz,f))
13202 {
13203 return qe_invalid;
13204 }
13205
2/2
✓ Branch 0 taken 19378 times.
✓ Branch 1 taken 8201258 times.
8220636 if(sz) //string found
13206 {
13207
1/2
✓ Branch 0 taken 19378 times.
✗ Branch 1 not taken.
19378 sc.strptr = new std::string();
13208 char dummy;
13209
2/2
✓ Branch 0 taken 1164508 times.
✓ Branch 1 taken 19378 times.
1183886 for(size_t q = 0; q < sz; ++q)
13210 {
13211
2/4
✓ Branch 0 taken 1164508 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164508 times.
✗ Branch 3 not taken.
1164508 if(!p_getc(&dummy,f))
13212 {
13213 return qe_invalid;
13214 }
13215
1/2
✓ Branch 0 taken 1164508 times.
✗ Branch 1 not taken.
1164508 sc.strptr->push_back(dummy);
13216 1164508 }
13217 19378 }
13218
2/4
✓ Branch 0 taken 8220636 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8220636 times.
✗ Branch 3 not taken.
8220636 if(!p_igetl(&sz,f))
13219 {
13220 return qe_invalid;
13221 }
13222
2/2
✓ Branch 0 taken 933 times.
✓ Branch 1 taken 8219703 times.
8220636 if(sz) //vector found
13223 {
13224
1/2
✓ Branch 0 taken 933 times.
✗ Branch 1 not taken.
933 sc.vecptr = new std::vector<int32_t>();
13225 int32_t dummy;
13226
2/2
✓ Branch 0 taken 11526 times.
✓ Branch 1 taken 933 times.
12459 for(size_t q = 0; q < sz; ++q)
13227 {
13228
2/4
✓ Branch 0 taken 11526 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11526 times.
✗ Branch 3 not taken.
11526 if(!p_igetl(&dummy,f))
13229 {
13230 return qe_invalid;
13231 }
13232
1/2
✓ Branch 0 taken 11526 times.
✗ Branch 1 not taken.
11526 sc.vecptr->push_back(dummy);
13233 11526 }
13234 933 }
13235 8220636 }
13236 }
13237 106871930 }
13238
13239 // If the first command is unknown, invalidate the whole thing.
13240 // Saw this for https://www.purezc.net/index.php?page=quests&id=411 hero script 0
13241
5/6
✓ Branch 0 taken 491569 times.
✓ Branch 1 taken 70839 times.
✓ Branch 2 taken 479395 times.
✓ Branch 3 taken 12174 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 479395 times.
562408 if (!zasm.empty() && zasm[0].command >= NUMCOMMANDS && zasm[0].command != 0xFFFF)
13242 {
13243 al_trace("Warning: found script with bad instruction, disabling script: %s %d\n", ScriptTypeToString(script->id.type), script->id.index);
13244 zasm.clear();
13245 }
13246
13247 562408 zasm_script_id id = zasm_scripts.size();
13248
3/6
✓ Branch 0 taken 562408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 562408 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 562408 times.
✗ Branch 5 not taken.
562408 auto& zs = zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, script->name(), std::move(zasm)));
13249 562408 script->zasm_script = zs;
13250 562408 script->pc = 0;
13251 562408 script->end_pc = zs->size;
13252
3/4
✓ Branch 0 taken 562408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12174 times.
✓ Branch 3 taken 550234 times.
562408 if (script->valid())
13253 {
13254
1/2
✓ Branch 0 taken 12174 times.
✗ Branch 1 not taken.
12174 zs->script_datas.push_back(script);
13255
1/2
✓ Branch 0 taken 12174 times.
✗ Branch 1 not taken.
12174 read_scripts.push_back(script);
13256 12174 }
13257
13258 562408 return 0;
13259 562408 }
13260
13261 extern SAMPLE customsfxdata[WAV_COUNT];
13262 extern uint8_t customsfxflag[WAV_COUNT>>3];
13263 extern int32_t sfxdat;
13264 extern DATAFILE *sfxdata;
13265 const char *old_sfx_string[Z35] =
13266 {
13267 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13268 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13269 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13270 "Hookshot", "Message", "Hero is hit", "Item fanfare", "Bomb placed", "Item pickup",
13271 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13272 "Secret chime", "Hero dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13273 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13274 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13275 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13276 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13277 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13278 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13279 };
13280 char *sfx_string[WAV_COUNT];
13281
13282 384 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13283 {
13284 //these are here to bypass compiler warnings about unused arguments
13285 384 Header=Header;
13286
13287 int32_t dummy;
13288 384 word s_version=0;
13289 //int32_t ret;
13290 384 SAMPLE temp_sample = {};
13291 384 temp_sample.loop_start=0;
13292 384 temp_sample.loop_end=0;
13293 384 temp_sample.param=0;
13294
13295 //section version info
13296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_igetw(&s_version,f))
13297 {
13298 return qe_invalid;
13299 }
13300
13301 384 FFCore.quest_format[vSFX] = s_version;
13302
13303
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!read_deprecated_section_cversion(f))
13304 {
13305 return qe_invalid;
13306 }
13307
13308 //section size
13309
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetl(&dummy,f))
13310 {
13311 return qe_invalid;
13312 }
13313
13314 /* HIGHLY UNORTHODOX UPDATING THING, by L
13315 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13316 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13317 * changing from 1 to 2.
13318 */
13319
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(s_version < 2)
13320 set_qr(qr_GOTOLESSNOTEQUAL,1);
13321
13322 /* End highly unorthodox updating thing */
13323
13324 384 int32_t wavcount = WAV_COUNT;
13325
13326
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(s_version < 6)
13327 wavcount = 128;
13328
13329 uint8_t tempflag[WAV_COUNT>>3];
13330
13331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(s_version < 4)
13332 {
13333 memset(tempflag, 0xFF, WAV_COUNT>>3);
13334 }
13335 else
13336 {
13337
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(s_version < 6)
13338 memset(tempflag, 0, WAV_COUNT>>3);
13339
13340
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 384 times.
12672 for(int32_t i=0; i<(wavcount>>3); i++)
13341 {
13342 12288 p_getc(&tempflag[i], f);
13343 12288 }
13344
13345 }
13346
13347
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(s_version>4)
13348 {
13349
2/2
✓ Branch 0 taken 97920 times.
✓ Branch 1 taken 384 times.
98304 for(int32_t i=1; i<WAV_COUNT; i++)
13350 {
13351 97920 sprintf(sfx_string[i],"s%03d",i);
13352
13353
2/2
✓ Branch 0 taken 74880 times.
✓ Branch 1 taken 23040 times.
97920 if((i<Z35))
13354 23040 strcpy(sfx_string[i], old_sfx_string[i-1]);
13355
13356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97920 times.
97920 if(i>=wavcount)
13357 continue;
13358
2/2
✓ Branch 0 taken 19637 times.
✓ Branch 1 taken 78283 times.
97920 if(get_bit(tempflag, i-1))
13359 {
13360 char tempname[36];
13361
13362
1/2
✓ Branch 0 taken 19637 times.
✗ Branch 1 not taken.
19637 if(!pfread(tempname, 36, f))
13363 {
13364 return qe_invalid;
13365 }
13366
13367 19637 sfx_string[i][0] = '\0';
13368 19637 strncat(sfx_string[i], tempname, 36 - 1);
13369 19637 }
13370 else
13371 {
13372 78283 sprintf(sfx_string[i],"s%03d",i);
13373
13374
2/2
✓ Branch 0 taken 68381 times.
✓ Branch 1 taken 9902 times.
78283 if(i<Z35)
13375 9902 strcpy(sfx_string[i], old_sfx_string[i-1]);
13376 78283 sfx_string[i][35] = 0; //Force NULL Termination
13377 }
13378 97920 }
13379 384 }
13380 else
13381 {
13382 for(int32_t i=1; i<WAV_COUNT; i++)
13383 {
13384 sprintf(sfx_string[i],"s%03d",i);
13385
13386 if(i<Z35)
13387 strcpy(sfx_string[i], old_sfx_string[i-1]);
13388 }
13389 }
13390
13391 //finally... section data
13392
2/2
✓ Branch 0 taken 97920 times.
✓ Branch 1 taken 384 times.
98304 for(int32_t i=1; i<wavcount; i++)
13393 {
13394
2/2
✓ Branch 0 taken 19637 times.
✓ Branch 1 taken 78283 times.
97920 if(get_bit(tempflag, i-1))
13395 {
13396
13397
1/2
✓ Branch 0 taken 19637 times.
✗ Branch 1 not taken.
19637 if(!p_igetl(&dummy,f))
13398 {
13399 return qe_invalid;
13400 }
13401
13402 19637 (temp_sample.bits) = dummy;
13403
13404
1/2
✓ Branch 0 taken 19637 times.
✗ Branch 1 not taken.
19637 if(!p_igetl(&dummy,f))
13405 {
13406 return qe_invalid;
13407 }
13408
13409 19637 (temp_sample.stereo) = dummy;
13410
13411
1/2
✓ Branch 0 taken 19637 times.
✗ Branch 1 not taken.
19637 if(!p_igetl(&dummy,f))
13412 {
13413 return qe_invalid;
13414 }
13415
13416 19637 (temp_sample.freq) = dummy;
13417
13418
1/2
✓ Branch 0 taken 19637 times.
✗ Branch 1 not taken.
19637 if(!p_igetl(&dummy,f))
13419 {
13420 return qe_invalid;
13421 }
13422
13423 19637 (temp_sample.priority) = dummy;
13424
13425
1/2
✓ Branch 0 taken 19637 times.
✗ Branch 1 not taken.
19637 if(!p_igetl(&(temp_sample.len),f))
13426 {
13427 return qe_invalid;
13428 }
13429
13430
1/2
✓ Branch 0 taken 19637 times.
✗ Branch 1 not taken.
19637 if(!p_igetl(&(temp_sample.loop_start),f))
13431 {
13432 return qe_invalid;
13433 }
13434
13435
1/2
✓ Branch 0 taken 19637 times.
✗ Branch 1 not taken.
19637 if(!p_igetl(&(temp_sample.loop_end),f))
13436 {
13437 return qe_invalid;
13438 }
13439
13440
1/2
✓ Branch 0 taken 19637 times.
✗ Branch 1 not taken.
19637 if(!p_igetl(&(temp_sample.param),f))
13441 {
13442 return qe_invalid;
13443 }
13444
13445 19637 auto len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13446 #ifdef ZC_FUZZ
13447 const int32_t sfx_limit = 100000;
13448 if (len < 0 || len > sfx_limit)
13449 {
13450 return qe_invalid;
13451 }
13452 #endif
13453 19637 temp_sample.data = calloc(len,1);
13454
13455
1/2
✓ Branch 0 taken 19637 times.
✗ Branch 1 not taken.
19637 if(s_version < 3)
13456 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13457
13458 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19637 times.
19637 if(s_version < 2)
13460 {
13461 if(!pfread(temp_sample.data, len,f))
13462 {
13463 return qe_invalid;
13464 }
13465 }
13466 else
13467 {
13468 //re-endianfy the data
13469 19637 int32_t wordstoread = len / sizeof(word);
13470
13471
2/2
✓ Branch 0 taken 546780069 times.
✓ Branch 1 taken 19637 times.
546799706 for(int32_t j=0; j<wordstoread; j++)
13472 {
13473 word temp;
13474
13475
1/2
✓ Branch 0 taken 546780069 times.
✗ Branch 1 not taken.
546780069 if(!p_igetw(&temp, f))
13476 {
13477 return qe_invalid;
13478 }
13479
13480 546780069 ((word *)temp_sample.data)[j] = temp;
13481 546780069 }
13482 }
13483 19637 }
13484
2/2
✓ Branch 0 taken 9902 times.
✓ Branch 1 taken 68381 times.
78283 else if(i < Z35)
13485 {
13486 9902 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13487 9902 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13488 9902 set_bit(tempflag, i-1, 1);
13489 9902 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13490 9902 temp_sample.data = calloc(len,1);
13491 9902 memcpy(temp_sample.data, datsamp->data, len);
13492 9902 }
13493 68381 else continue;
13494
13495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29539 times.
29539 if(customsfxdata[i].data!=NULL)
13496 {
13497 // delete [] customsfxdata[i].data;
13498 29539 free(customsfxdata[i].data);
13499 29539 }
13500
13501 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13502 29539 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13503 29539 customsfxdata[i].data = calloc(len2,1);
13504 29539 customsfxdata[i].bits = temp_sample.bits;
13505 29539 customsfxdata[i].stereo = temp_sample.stereo;
13506 29539 customsfxdata[i].freq = temp_sample.freq;
13507 29539 customsfxdata[i].priority = temp_sample.priority;
13508 29539 customsfxdata[i].len = temp_sample.len;
13509 29539 customsfxdata[i].loop_start = temp_sample.loop_start;
13510 29539 customsfxdata[i].loop_end = temp_sample.loop_end;
13511 29539 customsfxdata[i].param = temp_sample.param;
13512 29539 int32_t cpylen = len2;
13513
13514
1/2
✓ Branch 0 taken 29539 times.
✗ Branch 1 not taken.
29539 if(s_version<3)
13515 {
13516 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13517 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13518 }
13519
13520 29539 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13521
13522 29539 free(temp_sample.data);
13523 29539 }
13524
13525 384 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13526
13527 384 sfxdat=0;
13528 384 return 0;
13529 384 }
13530
13531 466 void setupsfx()
13532 {
13533
2/2
✓ Branch 0 taken 118830 times.
✓ Branch 1 taken 466 times.
119296 for(int32_t i=1; i<WAV_COUNT; i++)
13534 {
13535 118830 sprintf(sfx_string[i],"s%03d",i);
13536
13537
2/2
✓ Branch 0 taken 90870 times.
✓ Branch 1 taken 27960 times.
118830 if(i<Z35)
13538 {
13539 27960 strcpy(sfx_string[i], old_sfx_string[i-1]);
13540 27960 }
13541
13542 118830 memset(customsfxflag, 0, WAV_COUNT>>3);
13543
13544 118830 int32_t j=i;
13545
13546
2/2
✓ Branch 0 taken 28426 times.
✓ Branch 1 taken 90404 times.
118830 if(i>Z35)
13547 {
13548 90404 i=Z35;
13549 90404 }
13550
13551 118830 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13552
13553
2/2
✓ Branch 0 taken 91800 times.
✓ Branch 1 taken 27030 times.
118830 if(customsfxdata[j].data!=NULL)
13554 {
13555 // delete [] customsfxdata[j].data;
13556 27030 free(customsfxdata[j].data);
13557 27030 }
13558
13559 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13560 118830 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13561 118830 customsfxdata[j].bits = temp_sample->bits;
13562 118830 customsfxdata[j].stereo = temp_sample->stereo;
13563 118830 customsfxdata[j].freq = temp_sample->freq;
13564 118830 customsfxdata[j].priority = temp_sample->priority;
13565 118830 customsfxdata[j].len = temp_sample->len;
13566 118830 customsfxdata[j].loop_start = temp_sample->loop_start;
13567 118830 customsfxdata[j].loop_end = temp_sample->loop_end;
13568 118830 customsfxdata[j].param = temp_sample->param;
13569 118830 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13570 118830 i=j;
13571 118830 }
13572 466 }
13573
13574 extern char *guy_string[eMAXGUYS];
13575 extern const char *old_guy_string[OLDMAXGUYS];
13576
13577 466 int32_t readguys(PACKFILE *f, zquestheader *Header)
13578 {
13579
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 23 times.
466 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_guys);
13580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 466 times.
466 if (should_skip) return 0;
13581
13582 dword dummy;
13583 word guy_cversion;
13584 466 word guyversion=0;
13585
13586
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 443 times.
466 if(Header->zelda_version >= 0x193)
13587 {
13588 //section version info
13589
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetw(&guyversion,f))
13590 {
13591 return qe_invalid;
13592 }
13593
13594 443 FFCore.quest_format[vGuys] = guyversion;
13595
13596 // Note: this is the only instance where "cversion" is ever used.
13597
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetw(&guy_cversion,f))
13598 {
13599 return qe_invalid;
13600 }
13601
13602 //section size
13603
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetl(&dummy,f))
13604 {
13605 return qe_invalid;
13606 }
13607 443 }
13608
13609
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 82 times.
466 if(guyversion > 3)
13610 {
13611
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 384 times.
196992 for(int32_t i=0; i<MAXGUYS; i++)
13612 {
13613 char tempname[64];
13614
13615 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13616 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13617
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 196608 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
196608 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13618 {
13619 memset(tempname, 0, sizeof(char)*64);
13620 sprintf(tempname, "e%03d", i);
13621 strcpy(guy_string[i], tempname);
13622
13623 continue;
13624 }
13625
13626
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!pfread(tempname, 64, f))
13627 {
13628 return qe_invalid;
13629 }
13630
13631 // Don't retain names of uneditable enemy entries!
13632 // for version upgrade to 2.5
13633
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 196608 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
196608 if(guyversion < 23 && i >= 177)
13634 {
13635 // some of the older builds have names such as 'zz123',
13636 // (this order gets messed up with some eXXX and some zzXXX)
13637 // so let's update to the newer naming convection. -Gleeok
13638 char tmpbuf[64];
13639 memset(tmpbuf, 0, sizeof(char)*64);
13640 sprintf(tmpbuf, "zz%03d", i);
13641
13642 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13643 {
13644 memset(tempname, 0, sizeof(char)*64);
13645 sprintf(tempname, "e%03d", i);
13646 }
13647 }
13648
13649
6/6
✓ Branch 0 taken 67968 times.
✓ Branch 1 taken 128640 times.
✓ Branch 2 taken 64512 times.
✓ Branch 3 taken 3456 times.
✓ Branch 4 taken 55857 times.
✓ Branch 5 taken 8655 times.
196608 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13650 {
13651 187953 guy_string[i][0] = '\0';
13652 187953 strncat(guy_string[i], tempname, 64 - 1);
13653 187953 }
13654 else
13655 {
13656 8655 strcpy(guy_string[i],old_guy_string[i]);
13657 }
13658 196608 }
13659 384 }
13660 else
13661 {
13662
2/2
✓ Branch 0 taken 41984 times.
✓ Branch 1 taken 82 times.
42066 for(int32_t i=0; i<eMAXGUYS; i++)
13663 {
13664 41984 sprintf(guy_string[i],"zz%03d",i);
13665 41984 }
13666
13667
2/2
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 82 times.
14596 for(int32_t i=0; i<OLDMAXGUYS; i++)
13668 {
13669 14514 strcpy(guy_string[i],old_guy_string[i]);
13670 14514 }
13671 }
13672
13673
13674 //finally... section data
13675 466 init_guys(guyversion); //using default data for now...
13676
13677 // Goriya guy fix
13678
3/6
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
466 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13679 {
13680
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 60 times.
82 if(get_qr(qr_NEWENEMYTILES))
13681 {
13682 60 guysbuf[gGORIYA].tile=130;
13683 60 guysbuf[gGORIYA].e_tile=130;
13684 60 }
13685 82 }
13686
13687
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 23 times.
466 if(Header->zelda_version < 0x193)
13688 {
13689
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 5 times.
23 if(get_bit(deprecated_rules,46))
13690 {
13691 5 guysbuf[eDODONGO].cset=14;
13692 5 guysbuf[eDODONGO].bosspal=spDIG;
13693 5 }
13694 23 }
13695 // Not sure when this first changed, but it's necessary for 2.10, at least
13696 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13697 //2.10 Fixes
13698
3/6
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
466 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13699 {
13700 82 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13701 82 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13702 82 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13703 82 guysbuf[eCENT1].attributes[2] = 1;
13704 82 guysbuf[eCENT2].attributes[2] = 1;
13705 82 }
13706
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 466 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
466 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13707 {
13708 466 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13709 466 }
13710
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 82 times.
466 if(Header->zelda_version <= 0x210)
13711 {
13712 82 guysbuf[eGLEEOK1F].attributes[5] = 16;
13713 82 guysbuf[eGLEEOK2F].attributes[5] = 16;
13714 82 guysbuf[eGLEEOK3F].attributes[5] = 16;
13715 82 guysbuf[eGLEEOK4F].attributes[5] = 16;
13716
13717 82 guysbuf[eWIZ1].attributes[3] = 1; //only set the enemy that needs backward compat, not all of them.
13718 82 guysbuf[eBATROBE].attributes[3] = 1;
13719 //guysbuf[eSUMMONER].misc4 = 1;
13720 82 guysbuf[eWWIZ].attributes[3] = 1;
13721 82 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13722 82 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13723 82 }
13724
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 12 times.
466 if(Header->zelda_version == 0x190)
13725 {
13726 12 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13727 12 guysbuf[eKEESETRIB].attributes[2] = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13728 12 guysbuf[eGELTRIB].attributes[2] = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13729 12 }
13730
13731 // The versions here may not be correct
13732 // zelda_version>=0x211 handled at guyversion<24
13733
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 448 times.
466 if(Header->zelda_version <= 0x190)
13734 {
13735 18 guysbuf[eCENT1].attributes[2] = 0;
13736 18 guysbuf[eCENT2].attributes[2] = 0;
13737 18 guysbuf[eMOLDORM].attributes[1] = 0;
13738 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13739 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13740 18 }
13741
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 64 times.
448 else if(Header->zelda_version <= 0x210)
13742 {
13743 64 guysbuf[eCENT1].attributes[2] = 1;
13744 64 guysbuf[eCENT2].attributes[2] = 1;
13745 64 guysbuf[eMOLDORM].attributes[1] = 0;
13746 64 }
13747
13748
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 82 times.
466 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13749 {
13750 82 guysbuf[eKEESE1].attributes[15] = 120;
13751 82 guysbuf[eKEESE2].attributes[15] = 120;
13752 82 guysbuf[eKEESE3].attributes[15] = 120;
13753 82 guysbuf[eKEESETRIB].attributes[15] = 120;
13754 82 guysbuf[eKEESE1].attributes[16] = 16;
13755 82 guysbuf[eKEESE2].attributes[16] = 16;
13756 82 guysbuf[eKEESE3].attributes[16] = 16;
13757 82 guysbuf[eKEESETRIB].attributes[16] = 16;
13758
13759 82 guysbuf[ePEAHAT].attributes[15] = 80;
13760 82 guysbuf[ePEAHAT].attributes[16] = 16;
13761
13762 82 guysbuf[eGHINI2].attributes[15] = 120;
13763 82 guysbuf[eGHINI2].attributes[16] = 10;
13764
13765
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 66 times.
82 if (replay_version_check(20))
13766 {
13767 66 guysbuf[eGHINI2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13768 66 guysbuf[eMOLDORM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13769 66 guysbuf[eKEESETRIB].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13770 66 guysbuf[eKEESE3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13771 66 guysbuf[eKEESE2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13772 66 guysbuf[eKEESE1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13773 66 guysbuf[eTEK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13774 66 guysbuf[eTEK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13775 66 guysbuf[ePEAHAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13776 66 guysbuf[eROCK].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13777 66 guysbuf[eTRAP].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13778 66 guysbuf[eWALLM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13779 66 guysbuf[ePOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13780 66 guysbuf[eMANHAN].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13781 66 guysbuf[eGLEEOK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13782 66 guysbuf[eGLEEOK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13783 66 guysbuf[eGLEEOK3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13784 66 guysbuf[eGLEEOK4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13785 66 guysbuf[eDIG1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13786 66 guysbuf[eDIG3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13787 66 guysbuf[eDIGPUP1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13788 66 guysbuf[eDIGPUP2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13789 66 guysbuf[eDIGPUP3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13790 66 guysbuf[eDIGPUP4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13791 66 guysbuf[eRAQUAM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13792 66 guysbuf[eITEMFAIRY].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13793 66 guysbuf[eFIRE].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13794 66 guysbuf[eMANHAN2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13795 66 guysbuf[eTRAP_H].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13796 66 guysbuf[eTRAP_V].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13797 66 guysbuf[eTRAP_LR].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13798 66 guysbuf[eTRAP_UD].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13799 66 guysbuf[ePATRA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13800 66 guysbuf[ePATRA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13801 66 guysbuf[ePATRABS].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13802 66 guysbuf[eBAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13803 66 guysbuf[eGLEEOK1F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13804 66 guysbuf[eGLEEOK2F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13805 66 guysbuf[eGLEEOK3F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13806 66 guysbuf[eGLEEOK4F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13807 66 guysbuf[eTRIGGER].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13808 66 guysbuf[ePATRAL2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13809 66 guysbuf[ePATRAL3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13810 66 guysbuf[eGOHMA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13811 66 guysbuf[eGOHMA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13812 66 guysbuf[eGOHMA3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13813 66 guysbuf[eGOHMA4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13814 66 guysbuf[eMPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13815 66 guysbuf[eWPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13816 66 }
13817 82 }
13818
13819
13820
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(guyversion<=2)
13821 {
13822 82 return readherosprites2(f, guyversion==2?0:-1);
13823 }
13824
13825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(guyversion > 3)
13826 {
13827 guydata tempguy;
13828
13829
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 384 times.
196992 for(int32_t i=0; i<MAXGUYS; i++)
13830 {
13831
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 23) // May 2012 : 512 max enemies
13832 {
13833 if(i >= OLDBETAMAXGUYS)
13834 {
13835 memset(&guysbuf[i], 0, sizeof(guydata));
13836 continue;
13837 }
13838 }
13839
13840 196608 memset(&tempguy, 0, sizeof(guydata));
13841
13842 uint32_t flags1;
13843 uint32_t flags2;
13844
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetl(&(flags1),f))
13845 {
13846 return qe_invalid;
13847 }
13848
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetl(&(flags2),f))
13849 {
13850 return qe_invalid;
13851 }
13852 196608 tempguy.flags = guy_flags(flags1) | guy_flags(uint64_t(flags2)<<32ULL);
13853
13854
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 104960 times.
196608 if ( guyversion >= 36 ) //expanded tiles
13855 {
13856
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetl(&(tempguy.tile),f))
13857 {
13858 return qe_invalid;
13859 }
13860 91648 }
13861 else
13862 {
13863
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_igetw(&(tempguy.tile),f))
13864 {
13865 return qe_invalid;
13866 }
13867 }
13868
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_getc(&(tempguy.width),f))
13869 {
13870 return qe_invalid;
13871 }
13872
13873
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_getc(&(tempguy.height),f))
13874 {
13875 return qe_invalid;
13876 }
13877
13878
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 104960 times.
196608 if ( guyversion >= 36 ) //expanded tiles
13879 {
13880
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetl(&(tempguy.s_tile),f))
13881 {
13882 return qe_invalid;
13883 }
13884 91648 }
13885 else
13886 {
13887
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_igetw(&(tempguy.s_tile),f))
13888 {
13889 return qe_invalid;
13890 }
13891 }
13892
13893
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_getc(&(tempguy.s_width),f))
13894 {
13895 return qe_invalid;
13896 }
13897
13898
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_getc(&(tempguy.s_height),f))
13899 {
13900 return qe_invalid;
13901 }
13902
13903
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 104960 times.
196608 if ( guyversion >= 36 ) //expanded tiles
13904 {
13905
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetl(&(tempguy.e_tile),f))
13906 {
13907 return qe_invalid;
13908 }
13909 91648 }
13910 else
13911 {
13912
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_igetw(&(tempguy.e_tile),f))
13913 {
13914 return qe_invalid;
13915 }
13916 }
13917
13918
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_getc(&(tempguy.e_width),f))
13919 {
13920 return qe_invalid;
13921 }
13922
13923
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_getc(&(tempguy.e_height),f))
13924 {
13925 return qe_invalid;
13926 }
13927
13928
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.hp),f))
13929 {
13930 return qe_invalid;
13931 }
13932
13933
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.family),f))
13934 {
13935 return qe_invalid;
13936 }
13937
13938
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 196608 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
196608 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13939 {
13940 if(get_qr(qr_NEWENEMYTILES))
13941 {
13942 tempguy.s_tile=tempguy.e_tile+120;
13943 tempguy.s_width=tempguy.e_width;
13944 tempguy.s_height=tempguy.e_height;
13945 }
13946 else tempguy.s_tile=860;
13947 }
13948
13949
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.cset),f))
13950 {
13951 return qe_invalid;
13952 }
13953
13954
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.anim),f))
13955 {
13956 return qe_invalid;
13957 }
13958
13959
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.e_anim),f))
13960 {
13961 return qe_invalid;
13962 }
13963
13964
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.frate),f))
13965 {
13966 return qe_invalid;
13967 }
13968
13969
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.e_frate),f))
13970 {
13971 return qe_invalid;
13972 }
13973
13974
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 13) // April 2009
13975 {
13976 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
13977 {
13978 tempguy.frate *= 2;
13979 tempguy.e_frate *= 2;
13980 }
13981 }
13982
13983
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 14) // May 1 2009
13984 {
13985 if(tempguy.anim==a2FRMSLOW)
13986 {
13987 tempguy.anim=a2FRM;
13988 tempguy.frate *= 2;
13989 }
13990
13991 if(tempguy.e_anim==a2FRMSLOW)
13992 {
13993 tempguy.e_anim=a2FRM;
13994 tempguy.e_frate *= 2;
13995 }
13996
13997 if(tempguy.anim==aFLIPSLOW)
13998 {
13999 tempguy.anim=aFLIP;
14000 tempguy.frate *= 2;
14001 }
14002
14003 if(tempguy.e_anim==aFLIPSLOW)
14004 {
14005 tempguy.e_anim=aFLIP;
14006 tempguy.e_frate *= 2;
14007 }
14008
14009 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14010
14011 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14012
14013 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14014 {
14015 tempguy.anim=a4FRM4DIR;
14016 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14017 }
14018
14019 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14020 {
14021 tempguy.e_anim=a4FRM4DIR;
14022 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14023 }
14024 }
14025
14026
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.dp),f))
14027 {
14028 return qe_invalid;
14029 }
14030
14031 //correction for guy fire
14032
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 6)
14033 {
14034 if(i == gFIRE)
14035 tempguy.dp = 2;
14036 }
14037
14038
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.wdp),f))
14039 {
14040 return qe_invalid;
14041 }
14042
14043
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.weapon),f))
14044 {
14045 return qe_invalid;
14046 }
14047
14048 //correction for bosses using triple, "rising" fireballs
14049
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 5)
14050 {
14051 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14052 i == eGOHMA3 || i == eGOHMA4)
14053 {
14054 if(tempguy.weapon == ewFireball)
14055 tempguy.weapon = ewFireball2;
14056 }
14057 }
14058
14059
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.rate),f))
14060 {
14061 return qe_invalid;
14062 }
14063
14064
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.hrate),f))
14065 {
14066 return qe_invalid;
14067 }
14068
14069
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.step),f))
14070 {
14071 return qe_invalid;
14072 }
14073
14074 // HIGHLY UNORTHODOX UPDATING THING, part 2
14075
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 196608 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
196608 if(fixpolsvoice && tempguy.family==eePOLSV)
14076 {
14077 tempguy.step /= 2;
14078 }
14079
14080
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.homing),f))
14081 {
14082 return qe_invalid;
14083 }
14084
14085
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.grumble),f))
14086 {
14087 return qe_invalid;
14088 }
14089
14090
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.item_set),f))
14091 {
14092 return qe_invalid;
14093 }
14094
14095
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14096 {
14097
2/2
✓ Branch 0 taken 1966080 times.
✓ Branch 1 taken 196608 times.
2162688 for (int q = 0; q < 10; ++q)
14098 {
14099
1/2
✓ Branch 0 taken 1966080 times.
✗ Branch 1 not taken.
1966080 if (!p_igetl(&(tempguy.attributes[q]), f))
14100 {
14101 return qe_invalid;
14102 }
14103 1966080 }
14104 196608 }
14105 else
14106 {
14107 int16_t tempMisc;
14108
14109 for(int q=0;q<10;q++)
14110 {
14111 if (!p_igetw(&tempMisc, f))
14112 {
14113 return qe_invalid;
14114 }
14115 tempguy.attributes[q] = tempMisc;
14116 }
14117
14118 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14119 {
14120 if(tempguy.family == eeWIZZ && !(tempguy.attributes[0]))
14121 tempguy.attributes[4] = 74;
14122 }
14123
14124 }
14125
14126
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.bgsfx),f))
14127 {
14128 return qe_invalid;
14129 }
14130
14131
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.bosspal),f))
14132 {
14133 return qe_invalid;
14134 }
14135
14136
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.extend),f))
14137 {
14138 return qe_invalid;
14139 }
14140
14141 //! Enemy Defences
14142
14143 //If a 2.50 quest, use only the 2.5 defences.
14144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196608 times.
196608 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14145 {
14146
2/2
✓ Branch 0 taken 3735552 times.
✓ Branch 1 taken 196608 times.
3932160 for(int32_t j=0; j<edefLAST; j++)
14147 {
14148
1/2
✓ Branch 0 taken 3735552 times.
✗ Branch 1 not taken.
3735552 if(!p_getc(&(tempguy.defense[j]),f))
14149 {
14150 return qe_invalid;
14151 }
14152 3735552 }
14153 //then copy the generic script defence to all the new script defences
14154
14155 196608 }
14156
14157
14158
14159
14160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196608 times.
196608 if(guyversion >= 18)
14161 {
14162
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_getc(&(tempguy.hitsfx),f))
14163 {
14164 return qe_invalid;
14165 }
14166
14167
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_getc(&(tempguy.deadsfx),f))
14168 {
14169 return qe_invalid;
14170 }
14171 196608 }
14172
14173
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion >= 22)
14174 {
14175
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetl(&(tempguy.attributes[10]), f))
14176 {
14177 return qe_invalid;
14178 }
14179
14180
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetl(&(tempguy.attributes[11]),f))
14181 {
14182 return qe_invalid;
14183 }
14184 196608 }
14185 else if(guyversion >= 19)
14186 {
14187 int16_t tempMisc;
14188
14189 if(!p_igetw(&tempMisc,f))
14190 {
14191 return qe_invalid;
14192 }
14193
14194 tempguy.attributes[10] = tempMisc;
14195
14196 if(!p_igetw(&tempMisc,f))
14197 {
14198 return qe_invalid;
14199 }
14200
14201 tempguy.attributes[11] = tempMisc;
14202 }
14203
14204 //If a 2.54 or later quest, use all of the defences.
14205
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 91648 times.
196608 if(guyversion > 24) // Add new guyversion conditional statement
14206 {
14207
2/2
✓ Branch 0 taken 2016256 times.
✓ Branch 1 taken 91648 times.
2107904 for(int32_t j=edefLAST; j<edefLAST255; j++)
14208 {
14209
1/2
✓ Branch 0 taken 2016256 times.
✗ Branch 1 not taken.
2016256 if(!p_getc(&(tempguy.defense[j]),f))
14210 {
14211 return qe_invalid;
14212 }
14213 2016256 }
14214 91648 }
14215
14216
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 104960 times.
196608 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14217 {
14218
2/2
✓ Branch 0 taken 1049600 times.
✓ Branch 1 taken 104960 times.
1154560 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14219 {
14220 1049600 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14221 1049600 }
14222 104960 }
14223
14224 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14225
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 91648 times.
196608 if(guyversion > 25)
14226 {
14227
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetl(&(tempguy.txsz),f))
14228 {
14229 return qe_invalid;
14230 }
14231
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetl(&(tempguy.tysz),f))
14232 {
14233 return qe_invalid;
14234 }
14235
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetl(&(tempguy.hxsz),f))
14236 {
14237 return qe_invalid;
14238 }
14239
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetl(&(tempguy.hysz),f))
14240 {
14241 return qe_invalid;
14242 }
14243
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetl(&(tempguy.hzsz),f))
14244 {
14245 return qe_invalid;
14246 }
14247 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14248
14249 */
14250 91648 }
14251 //More Enemy Editor vars for 2.60
14252
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 91648 times.
196608 if(guyversion > 26)
14253 {
14254
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetl(&(tempguy.hxofs),f))
14255 {
14256 return qe_invalid;
14257 }
14258
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetl(&(tempguy.hyofs),f))
14259 {
14260 return qe_invalid;
14261 }
14262
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetl(&(tempguy.xofs),f))
14263 {
14264 return qe_invalid;
14265 }
14266
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetl(&(tempguy.yofs),f))
14267 {
14268 return qe_invalid;
14269 }
14270
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetl(&(tempguy.zofs),f))
14271 {
14272 return qe_invalid;
14273 }
14274 91648 }
14275
14276
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 104960 times.
196608 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14277 {
14278 104960 tempguy.wpnsprite = 0;
14279 104960 }
14280
14281
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 91648 times.
196608 if(guyversion > 27)
14282 {
14283
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetl(&(tempguy.wpnsprite),f))
14284 {
14285 return qe_invalid;
14286 }
14287 91648 }
14288
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 104960 times.
196608 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14289 {
14290 104960 tempguy.SIZEflags = 0;
14291 104960 }
14292
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 91648 times.
196608 if(guyversion > 28)
14293 {
14294
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetl(&(tempguy.SIZEflags),f))
14295 {
14296 return qe_invalid;
14297 }
14298
14299 91648 }
14300
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 104960 times.
196608 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14301 {
14302 104960 tempguy.frozentile = 0;
14303 104960 tempguy.frozencset = 0;
14304 104960 tempguy.frozenclock = 0;
14305
2/2
✓ Branch 0 taken 1049600 times.
✓ Branch 1 taken 104960 times.
1154560 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14306 104960 }
14307
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 91648 times.
196608 if(guyversion >= 30)
14308 {
14309
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetl(&(tempguy.frozentile),f))
14310 {
14311 return qe_invalid;
14312 }
14313
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetl(&(tempguy.frozencset),f))
14314 {
14315 return qe_invalid;
14316 }
14317
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetl(&(tempguy.frozenclock),f))
14318 {
14319 return qe_invalid;
14320 }
14321
2/2
✓ Branch 0 taken 916480 times.
✓ Branch 1 taken 91648 times.
1008128 for ( int32_t q = 0; q < 10; q++ ) {
14322
1/2
✓ Branch 0 taken 916480 times.
✗ Branch 1 not taken.
916480 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14323 {
14324 return qe_invalid;
14325 }
14326 916480 }
14327
14328 91648 }
14329
14330
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 91648 times.
196608 if(guyversion >= 34)
14331 {
14332
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetw(&(tempguy.firesfx),f))
14333 {
14334 return qe_invalid;
14335 }
14336
2/2
✓ Branch 0 taken 1558016 times.
✓ Branch 1 taken 91648 times.
1649664 for(int q=15;q<32;++q)
14337 {
14338
1/2
✓ Branch 0 taken 1558016 times.
✗ Branch 1 not taken.
1558016 if(!p_igetl(&(tempguy.attributes[q]),f))
14339 {
14340 return qe_invalid;
14341 }
14342 1558016 }
14343
14344
2/2
✓ Branch 0 taken 2932736 times.
✓ Branch 1 taken 91648 times.
3024384 for ( int32_t q = 0; q < 32; q++ ) {
14345
1/2
✓ Branch 0 taken 2932736 times.
✗ Branch 1 not taken.
2932736 if(!p_igetl(&(tempguy.movement[q]),f))
14346 {
14347 return qe_invalid;
14348 }
14349 2932736 }
14350
2/2
✓ Branch 0 taken 2932736 times.
✓ Branch 1 taken 91648 times.
3024384 for ( int32_t q = 0; q < 32; q++ ) {
14351
1/2
✓ Branch 0 taken 2932736 times.
✗ Branch 1 not taken.
2932736 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14352 {
14353 return qe_invalid;
14354 }
14355 2932736 }
14356
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetw(&(tempguy.script),f))
14357 {
14358 return qe_invalid;
14359 }
14360
2/2
✓ Branch 0 taken 733184 times.
✓ Branch 1 taken 91648 times.
824832 for ( int32_t q = 0; q < 8; q++ )
14361 {
14362
1/2
✓ Branch 0 taken 733184 times.
✗ Branch 1 not taken.
733184 if(!p_igetl(&(tempguy.initD[q]),f))
14363 {
14364 return qe_invalid;
14365 }
14366 733184 }
14367
2/2
✓ Branch 0 taken 183296 times.
✓ Branch 1 taken 91648 times.
274944 for ( int32_t q = 0; q < 2; q++ )
14368 {
14369 int32_t temp;
14370
1/2
✓ Branch 0 taken 183296 times.
✗ Branch 1 not taken.
183296 if(!p_igetl(&temp,f))
14371 {
14372 return qe_invalid;
14373 }
14374 183296 }
14375
14376 91648 }
14377
14378
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 91648 times.
196608 if(guyversion >= 37)
14379 {
14380
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetl(&(tempguy.editorflags),f))
14381 {
14382 return qe_invalid;
14383 }
14384 91648 }
14385
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 104960 times.
196608 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14386
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 91648 times.
196608 if(guyversion >= 38)
14387 {
14388
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetl(&(tempguy.attributes[12]),f))
14389 {
14390 return qe_invalid;
14391 }
14392
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetl(&(tempguy.attributes[13]),f))
14393 {
14394 return qe_invalid;
14395 }
14396
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetl(&(tempguy.attributes[14]),f))
14397 {
14398 return qe_invalid;
14399 }
14400
14401 91648 }
14402
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 104960 times.
196608 if ( guyversion < 38 )
14403 {
14404 104960 tempguy.attributes[12] = 0;
14405 104960 tempguy.attributes[13] = 0;
14406 104960 tempguy.attributes[14] = 0;
14407 104960 }
14408
14409
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 91648 times.
196608 if ( guyversion >= 39 )
14410 {
14411
2/2
✓ Branch 0 taken 733184 times.
✓ Branch 1 taken 91648 times.
824832 for ( int32_t q = 0; q < 8; q++ )
14412 {
14413
2/2
✓ Branch 0 taken 47656960 times.
✓ Branch 1 taken 733184 times.
48390144 for ( int32_t w = 0; w < 65; w++ )
14414 {
14415
1/2
✓ Branch 0 taken 47656960 times.
✗ Branch 1 not taken.
47656960 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14416 {
14417 return qe_invalid;
14418 }
14419 47656960 }
14420
2/2
✓ Branch 0 taken 47656960 times.
✓ Branch 1 taken 733184 times.
48390144 for ( int32_t w = 0; w < 65; w++ )
14421 {
14422
1/2
✓ Branch 0 taken 47656960 times.
✗ Branch 1 not taken.
47656960 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f))
14423 {
14424 return qe_invalid;
14425 }
14426 47656960 }
14427 733184 }
14428
14429
14430 91648 }
14431
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 104960 times.
196608 if ( guyversion < 39 ) //apply old InitD strings to both
14432 {
14433
2/2
✓ Branch 0 taken 839680 times.
✓ Branch 1 taken 104960 times.
944640 for ( int32_t q = 0; q < 8; q++ )
14434 {
14435 839680 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14436 839680 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14437 839680 }
14438 104960 }
14439
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 91648 times.
196608 if ( guyversion >= 40 )
14440 {
14441
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_igetw(&(tempguy.weaponscript),f))
14442 {
14443 return qe_invalid;
14444 }
14445 91648 }
14446
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 104960 times.
196608 if ( guyversion < 40 )
14447 {
14448 104960 tempguy.weaponscript = 0;
14449 104960 }
14450 //eweapon script InitD
14451
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 91648 times.
196608 if ( guyversion >= 41 )
14452 {
14453
2/2
✓ Branch 0 taken 733184 times.
✓ Branch 1 taken 91648 times.
824832 for ( int32_t q = 0; q < 8; q++ )
14454 {
14455
1/2
✓ Branch 0 taken 733184 times.
✗ Branch 1 not taken.
733184 if(!p_igetl(&(tempguy.weap_initiald[q]),f))
14456 {
14457 return qe_invalid;
14458 }
14459 733184 }
14460
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if ( guy_cversion < 4 )
14461 {
14462 if ( tempguy.family == eeKEESE )
14463 {
14464
14465 if ( !tempguy.attributes[0] )
14466 {
14467 tempguy.attributes[15] = 120;
14468 tempguy.attributes[16] = 16;
14469
14470 }
14471 }
14472 if ( tempguy.family == eePEAHAT )
14473 {
14474 tempguy.attributes[15] = 80;
14475 tempguy.attributes[16] = 16;
14476 }
14477
14478 if ( tempguy.family == eeGHINI )
14479 {
14480 tempguy.attributes[15] = 120;
14481 tempguy.attributes[16] = 10;
14482 }
14483
14484 }
14485 91648 }
14486
14487
14488
14489 //default weapon sprites (quest version < 2.54)
14490 //port over old defaults -Z
14491
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 104960 times.
196608 if(guyversion < 32)
14492 {
14493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if ( tempguy.wpnsprite <= 0 )
14494 {
14495
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2911 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89121 times.
✓ Branch 4 taken 817 times.
✓ Branch 5 taken 708 times.
✓ Branch 6 taken 1938 times.
✓ Branch 7 taken 1316 times.
✓ Branch 8 taken 2445 times.
✓ Branch 9 taken 211 times.
✓ Branch 10 taken 78 times.
✓ Branch 11 taken 457 times.
✓ Branch 12 taken 79 times.
✓ Branch 13 taken 924 times.
✓ Branch 14 taken 1849 times.
✓ Branch 15 taken 234 times.
✓ Branch 16 taken 332 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1540 times.
104960 switch(tempguy.weapon)
14496 {
14497 case wNone:
14498 89121 tempguy.wpnsprite = 0; break;
14499
14500 case wSword:
14501 case wBeam:
14502 case wBrang:
14503 case wBomb:
14504 case wSBomb:
14505 case wLitBomb:
14506 case wLitSBomb:
14507 case wArrow:
14508 case wFire:
14509 case wWhistle:
14510 case wBait:
14511 case wWand:
14512 case wMagic:
14513 case wCatching:
14514 case wWind:
14515 case wRefMagic:
14516 case wRefFireball:
14517 case wRefRock:
14518 case wHammer:
14519 case wHookshot:
14520 case wHSHandle:
14521 case wHSChain:
14522 case wSSparkle:
14523 case wFSparkle:
14524 case wSmack:
14525 case wPhantom:
14526 case wCByrna:
14527 case wRefBeam:
14528 case wStomp:
14529 case lwMax:
14530 case wScript1:
14531 case wScript2:
14532 case wScript3:
14533 case wScript4:
14534 case wScript5:
14535 case wScript6:
14536 case wScript7:
14537 case wScript8:
14538 case wScript9:
14539 case wScript10:
14540 case wIce:
14541 //Cannot use any of these weapons yet.
14542 tempguy.wpnsprite = -1;
14543 break;
14544
14545 case wEnemyWeapons:
14546 2911 case ewFireball: tempguy.wpnsprite = 17; break;
14547
14548 817 case ewArrow: tempguy.wpnsprite = 19; break;
14549 708 case ewBrang: tempguy.wpnsprite = 4; break;
14550 1938 case ewSword: tempguy.wpnsprite = 20; break;
14551 1316 case ewRock: tempguy.wpnsprite = 18; break;
14552 2445 case ewMagic: tempguy.wpnsprite = 21; break;
14553 211 case ewBomb: tempguy.wpnsprite = 78; break;
14554 78 case ewSBomb: tempguy.wpnsprite = 79; break;
14555 457 case ewLitBomb: tempguy.wpnsprite = 76; break;
14556 79 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14557 924 case ewFireTrail: tempguy.wpnsprite = 80; break;
14558 1849 case ewFlame: tempguy.wpnsprite = 35; break;
14559 234 case ewWind: tempguy.wpnsprite = 36; break;
14560 332 case ewFlame2: tempguy.wpnsprite = 81; break;
14561 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14562 case ewIce: tempguy.wpnsprite = 83; break;
14563 1540 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14564
14565
14566 default: break; //No assign.
14567 }
14568 104960 }
14569 104960 }
14570
14571 //default weapon fire sound (quest version < 2.54)
14572 //port over old defaults and zero new data. -Z
14573
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 104960 times.
196608 if(guyversion < 34)
14574 {
14575
2/2
✓ Branch 0 taken 3358720 times.
✓ Branch 1 taken 104960 times.
3463680 for ( int32_t q = 0; q < 32; q++ )
14576 {
14577 3358720 tempguy.movement[q] = 0;
14578 3358720 tempguy.new_weapon[q] = 0;
14579
14580 3358720 }
14581
14582 //NPC Script attributes.
14583 104960 tempguy.script = 0; //No scripted enemies existed. -Z
14584
2/2
✓ Branch 0 taken 839680 times.
✓ Branch 1 taken 104960 times.
944640 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14585
14586
2/2
✓ Branch 0 taken 1784320 times.
✓ Branch 1 taken 104960 times.
1889280 for ( int32_t q = 15; q < 32; q++) tempguy.attributes[q] = 0; //misc 16-32
14587
14588 //old default sounds
14589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if ( tempguy.firesfx <= 0 )
14590 {
14591
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2911 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89121 times.
✓ Branch 4 taken 817 times.
✓ Branch 5 taken 708 times.
✓ Branch 6 taken 1938 times.
✓ Branch 7 taken 1316 times.
✓ Branch 8 taken 2445 times.
✓ Branch 9 taken 211 times.
✓ Branch 10 taken 78 times.
✓ Branch 11 taken 457 times.
✓ Branch 12 taken 79 times.
✓ Branch 13 taken 924 times.
✓ Branch 14 taken 1849 times.
✓ Branch 15 taken 234 times.
✓ Branch 16 taken 332 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1540 times.
104960 switch(tempguy.weapon)
14592 {
14593 case wNone:
14594 89121 tempguy.firesfx = 0; break;
14595
14596 case wSword:
14597 case wBeam:
14598 case wBrang:
14599 case wBomb:
14600 case wSBomb:
14601 case wLitBomb:
14602 case wLitSBomb:
14603 case wArrow:
14604 case wFire:
14605 case wWhistle:
14606 case wBait:
14607 case wWand:
14608 case wMagic:
14609 case wCatching:
14610 case wWind:
14611 case wRefMagic:
14612 case wRefFireball:
14613 case wRefRock:
14614 case wHammer:
14615 case wHookshot:
14616 case wHSHandle:
14617 case wHSChain:
14618 case wSSparkle:
14619 case wFSparkle:
14620 case wSmack:
14621 case wPhantom:
14622 case wCByrna:
14623 case wRefBeam:
14624 case wStomp:
14625 case lwMax:
14626 case wScript1:
14627 case wScript2:
14628 case wScript3:
14629 case wScript4:
14630 case wScript5:
14631 case wScript6:
14632 case wScript7:
14633 case wScript8:
14634 case wScript9:
14635 case wScript10:
14636 case wIce:
14637 //Cannot use any of these weapons yet.
14638 tempguy.firesfx = -1;
14639 break;
14640
14641 case wEnemyWeapons:
14642 2911 case ewFireball: tempguy.firesfx = 40; break;
14643
14644 817 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14645 708 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14646 1938 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14647 1316 case ewRock: tempguy.firesfx = 51; break;
14648 2445 case ewMagic: tempguy.firesfx = 32; break;
14649 211 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14650 78 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14651 457 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14652 79 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14653 924 case ewFireTrail: tempguy.firesfx = 13; break;
14654 1849 case ewFlame: tempguy.firesfx = 13; break;
14655 234 case ewWind: tempguy.firesfx = 32; break;
14656 332 case ewFlame2: tempguy.firesfx = 13; break;
14657 case ewFlame2Trail: tempguy.firesfx = 13; break;
14658 case ewIce: tempguy.firesfx = 44; break;
14659 1540 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14660
14661 //what about special attacks (e.g. summoning == 56)
14662 default: break; //No assign.
14663 }
14664 104960 }
14665 104960 }
14666
14667 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14668
4/6
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 104960 times.
✓ Branch 2 taken 91648 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 91648 times.
196608 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14669 {
14670
2/2
✓ Branch 0 taken 14184 times.
✓ Branch 1 taken 90776 times.
104960 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14671 104960 }
14672 //Keese and bat halt rates.
14673
3/4
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 91648 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104960 times.
196608 if ( guyversion < 42 && guy_cversion < 4 )
14674 {
14675
14676
2/2
✓ Branch 0 taken 103636 times.
✓ Branch 1 taken 1324 times.
104960 if ( tempguy.family == eeKEESE )
14677 {
14678
14679
2/2
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 955 times.
1324 if ( !tempguy.attributes[0] )
14680 {
14681 955 tempguy.attributes[15] = 120;
14682 955 tempguy.attributes[16] = 16;
14683
14684 955 }
14685 1324 }
14686
2/2
✓ Branch 0 taken 104486 times.
✓ Branch 1 taken 474 times.
104960 if ( tempguy.family == eePEAHAT )
14687 {
14688 474 tempguy.attributes[15] = 80;
14689 474 tempguy.attributes[16] = 16;
14690 474 }
14691
2/2
✓ Branch 0 taken 104755 times.
✓ Branch 1 taken 205 times.
104960 if ( tempguy.family == eeGHINI )
14692 {
14693 205 tempguy.attributes[15] = 120;
14694 205 tempguy.attributes[16] = 10;
14695 205 }
14696
14697
14698 104960 }
14699
14700
14701 //miscellaneous other corrections
14702 //fix the mirror wizzrobe -DD
14703
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 7)
14704 {
14705 if(i == eMWIZ)
14706 {
14707 tempguy.attributes[1] = 0;
14708 tempguy.attributes[3] = 1;
14709 }
14710 }
14711
14712
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 8)
14713 {
14714 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14715 {
14716 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14717 tempguy.attributes[4] = 4; //neck length in segments
14718 tempguy.attributes[5] = 8; //neck offset from first body tile
14719 tempguy.attributes[6] = 40; //offset for each subsequent neck tile from the first neck tile
14720 tempguy.attributes[7] = 168; //head offset from first body tile
14721 tempguy.attributes[8] = 228; //flying head offset from first body tile
14722
14723 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14724 {
14725 tempguy.attributes[5] += 10; //neck offset from first body tile
14726 tempguy.attributes[7] -= 12; //head offset from first body tile
14727 }
14728 }
14729 }
14730
14731
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14732 {
14733 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.attributes[0]==0)
14734 tempguy.bosspal = spDIG;
14735 }
14736
14737
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 11) // December 2007 - Spinning Tile fix
14738 {
14739 if(tempguy.family==eeSPINTILE)
14740 {
14741 tempguy.flags |= guy_superman;
14742 tempguy.item_set = 0; // Don't drop items
14743 tempguy.step = 300;
14744 }
14745 }
14746
14747
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14748 {
14749 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14750 {
14751 if(tempguy.family==eeROPE)
14752 {
14753 tempguy.flags &= ~guy_flashing;
14754 }
14755 }
14756
14757 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14758 {
14759 if(tempguy.family==eeBUBBLE)
14760 {
14761 tempguy.flags &= ~guy_flashing;
14762 }
14763 }
14764
14765 if((tempguy.family==eeGHINI)&&(tempguy.attributes[0]))
14766 {
14767 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14768 {
14769 tempguy.flags |= guy_blinking;
14770 }
14771
14772 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14773 {
14774 tempguy.flags |= guy_transparent;
14775 }
14776 }
14777 }
14778
14779
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14780 {
14781 if(i==gFIRE)
14782 {
14783 tempguy.e_anim = aFLIP;
14784 tempguy.e_frate = 24;
14785 }
14786
14787 if(i==gFAIRY)
14788 {
14789 tempguy.e_anim = a2FRM;
14790 tempguy.e_frate = 16;
14791 }
14792 }
14793
14794
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14795 {
14796 if(i==0) Z_message("Updating guys to version 16...\n");
14797
14798 update_guy_1(&tempguy);
14799
14800 if(i==eMPOLSV)
14801 {
14802 tempguy.defense[edefARROW] = edCHINK;
14803 tempguy.defense[edefMAGIC] = ed1HKO;
14804 tempguy.defense[edefREFMAGIC] = ed1HKO;
14805 }
14806 }
14807
14808
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 17) // December 2009
14809 {
14810 if(tempguy.family==eePROJECTILE)
14811 {
14812 tempguy.attributes[0] = 0;
14813 }
14814 }
14815
14816
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 18) // January 2010
14817 {
14818 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
14819 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
14820
14821 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
14822 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.attributes[9] == 0)) ? WAV_GASP : WAV_EDEAD;
14823
14824 if(tempguy.family == eeAQUA)
14825 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
14826 else if(tempguy.family == eeMANHAN)
14827 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
14828 else if(tempguy.family==eePATRA)
14829 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14830 else if(tempguy.family==eeGHOMA)
14831 {
14832 for(int32_t j=0; j<edefLAST; j++)
14833 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
14834
14835 tempguy.defense[edefARROW] = ((tempguy.attributes[0]==3) ? edCHINKL8 : (tempguy.attributes[0]==2) ? edCHINKL4 : 0);
14836
14837 if(tempguy.attributes[0]==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
14838
14839 tempguy.attributes[0]--;
14840 }
14841 else if(tempguy.family == eeGLEEOK)
14842 {
14843 for(int32_t j=0; j<edefLAST; j++)
14844 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14845
14846 if(tempguy.attributes[2]==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
14847 }
14848 else if(tempguy.family == eeARMOS)
14849 {
14850 tempguy.family=eeWALK;
14851 tempguy.hrate = 0;
14852 tempguy.attributes[9] = tempguy.attributes[0];
14853 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
14854 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
14855 tempguy.attributes[8] = e9tARMOS;
14856 }
14857 else if(tempguy.family == eeGHINI && !tempguy.attributes[0])
14858 {
14859 tempguy.family=eeWALK;
14860 tempguy.hrate = 0;
14861 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] =
14862 tempguy.attributes[6] = tempguy.attributes[7] = tempguy.attributes[8] = tempguy.attributes[9] = 0;
14863 }
14864
14865 // Spawn animation flags
14866 if(tempguy.family == eeWALK && (tempguy.flags&guy_armos || tempguy.flags&guy_ghini))
14867 tempguy.flags |= guy_fade_flicker;
14868 else
14869 tempguy.flags &= (guy_flags)0x0F00000F; // Get rid of the unused flags!
14870 }
14871
14872
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 20) // April 2010
14873 {
14874 if(tempguy.family == eeTRAP)
14875 {
14876 tempguy.attributes[1] = tempguy.attributes[9];
14877
14878 if(tempguy.attributes[9]>=1)
14879 {
14880 tempguy.attributes[0]++;
14881 }
14882
14883 tempguy.attributes[9] = 0;
14884 }
14885
14886 // Bomb Blast fix
14887 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
14888 tempguy.weapon = ewLitBomb;
14889 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
14890 tempguy.weapon = ewLitSBomb;
14891 }
14892
14893
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 21) // September 2011
14894 {
14895 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
14896 {
14897 if(tempguy.family == eeKEESETRIB)
14898 {
14899 tempguy.family = eeKEESE;
14900 tempguy.attributes[1] = e2tKEESETRIB;
14901 tempguy.attributes[0] = 0;
14902 }
14903
14904 tempguy.rate = 2;
14905 tempguy.hrate = 8;
14906 tempguy.homing = 0;
14907 tempguy.step= (tempguy.family == eeKEESE && tempguy.attributes[0] ? 100:62);
14908 }
14909 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
14910 {
14911 if(tempguy.family == eePEAHAT)
14912 {
14913 tempguy.rate = 4;
14914 tempguy.step = 62;
14915 }
14916 else
14917 tempguy.step = 25;
14918
14919 tempguy.hrate = 8;
14920 tempguy.homing = 0;
14921 }
14922 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
14923 {
14924 if(tempguy.family == eeMANHAN)
14925 tempguy.step=50;
14926
14927 tempguy.hrate = 16;
14928 tempguy.homing = 0;
14929 }
14930 else if(tempguy.family == eeGLEEOK)
14931 {
14932 tempguy.rate = 2;
14933 tempguy.homing = 0;
14934 tempguy.hrate = 9;
14935 tempguy.step=89;
14936 }
14937 else if(tempguy.family == eeGHINI)
14938 {
14939 tempguy.rate = 4;
14940 tempguy.hrate = 12;
14941 tempguy.step=62;
14942 tempguy.homing = 0;
14943 }
14944
14945 // Bigdig random rate fix
14946 if(tempguy.family==eeDIG && tempguy.attributes[9]==1)
14947 {
14948 tempguy.rate = 2;
14949 }
14950 }
14951
14952
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 24) // November 2012
14953 {
14954 if(tempguy.family==eeLANM)
14955 tempguy.attributes[2] = 1;
14956 else if(tempguy.family==eeMOLD)
14957 tempguy.attributes[1] = 0;
14958 }
14959
14960
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 104960 times.
196608 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
14961 {
14962
2/2
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 103530 times.
104960 if(tempguy.family!=eeDIG)
14963 {
14964 103530 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
14965 103530 }
14966
14967 104960 }
14968 // does not seem to solve the issue!
14969
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if ( Header->zelda_version <= 0x210 )
14970 {
14971 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
14972 if ( tempguy.family == eeDONGO )
14973 {
14974 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
14975 }
14976 }
14977
14978
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 104960 times.
196608 if(guyversion >= 42)
14979 {
14980
2/2
✓ Branch 0 taken 89088 times.
✓ Branch 1 taken 2560 times.
91648 if(guyversion >= 47)
14981 {
14982
1/2
✓ Branch 0 taken 89088 times.
✗ Branch 1 not taken.
89088 if(!p_igetl(&(tempguy.moveflags),f))
14983 {
14984 return qe_invalid;
14985 }
14986 89088 }
14987 else
14988 {
14989 byte fl;
14990
1/2
✓ Branch 0 taken 2560 times.
✗ Branch 1 not taken.
2560 if(!p_getc(&fl,f))
14991 {
14992 return qe_invalid;
14993 }
14994 2560 tempguy.moveflags = (move_flags)fl;
14995 }
14996 91648 }
14997 else
14998 {
14999
7/8
✓ Branch 0 taken 3146 times.
✓ Branch 1 taken 82805 times.
✓ Branch 2 taken 2767 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 970 times.
✓ Branch 5 taken 655 times.
✓ Branch 6 taken 508 times.
✓ Branch 7 taken 14109 times.
104960 switch(tempguy.family)
15000 {
15001 //No gravity; floats over pits
15002 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15003 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15004 //Special (bosses, etc)
15005 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15006 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15007 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15008 82805 tempguy.moveflags = move_can_pitwalk;
15009 82805 break;
15010 //No gravity, but falls in pits
15011 case eeLEV:
15012 970 tempguy.moveflags = move_can_pitfall;
15013 970 break;
15014 //Bosses that respect pits
15015 case eeDONGO:
15016 655 tempguy.moveflags = move_obeys_grav;
15017 655 break;
15018 case eeLANM:
15019 508 tempguy.moveflags = move_none;
15020 508 break;
15021 //Gravity, floats over pits
15022 case eeWIZZ: case eeWALLM: case eeGHINI:
15023 2767 tempguy.moveflags = move_obeys_grav | move_can_pitwalk;
15024 2767 break;
15025 //Gravity and falls in pits
15026 case eeWALK:
15027
4/4
✓ Branch 0 taken 13399 times.
✓ Branch 1 taken 710 times.
✓ Branch 2 taken 538 times.
✓ Branch 3 taken 12861 times.
14109 if (tempguy.attributes[8]==e9tPOLSVOICE||tempguy.attributes[8]==e9tVIRE)
15028 1248 break;
15029 [[fallthrough]];
15030 case eeOTHER:
15031 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15032 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15033 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15034 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15035 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15036 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15037 16007 tempguy.moveflags = move_obeys_grav | move_can_pitfall;
15038 16007 }
15039 }
15040
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 104960 times.
196608 if(guyversion < 43)
15041 {
15042
2/2
✓ Branch 0 taken 85572 times.
✓ Branch 1 taken 19388 times.
104960 switch(tempguy.family)
15043 {
15044 //No gravity; floats over pits
15045 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15046 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15047 //Special (bosses, etc)
15048 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15049 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15050 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15051 case eeWIZZ: case eeWALLM: case eeGHINI:
15052 //Gravity, floats over pits
15053 85572 tempguy.moveflags |= move_can_waterwalk;
15054 85572 tempguy.moveflags |= move_can_pitwalk;
15055 85572 break;
15056 }
15057 104960 }
15058
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 104960 times.
196608 if (guyversion < 44)
15059 {
15060
2/2
✓ Branch 0 taken 104028 times.
✓ Branch 1 taken 932 times.
104960 if ( tempguy.family == eeGHOMA )
15061 {
15062 932 tempguy.flags |= guy_fade_instant;
15063 932 }
15064 104960 }
15065
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 104960 times.
196608 if (guyversion > 44)
15066 {
15067
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_getc(&(tempguy.spr_shadow),f))
15068 {
15069 return qe_invalid;
15070 }
15071
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_getc(&(tempguy.spr_death),f))
15072 {
15073 return qe_invalid;
15074 }
15075
1/2
✓ Branch 0 taken 91648 times.
✗ Branch 1 not taken.
91648 if(!p_getc(&(tempguy.spr_spawn),f))
15076 {
15077 return qe_invalid;
15078 }
15079 91648 }
15080 else
15081 {
15082
2/2
✓ Branch 0 taken 104553 times.
✓ Branch 1 taken 407 times.
104960 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.attributes[9]==1) ? iwLargeShadow : iwShadow;
15083 104960 tempguy.spr_death = iwDeath;
15084 104960 tempguy.spr_spawn = iwSpawn;
15085 }
15086
15087
2/2
✓ Branch 0 taken 91648 times.
✓ Branch 1 taken 104960 times.
196608 if(guyversion < 46)
15088 {
15089
4/4
✓ Branch 0 taken 14109 times.
✓ Branch 1 taken 90851 times.
✓ Branch 2 taken 13399 times.
✓ Branch 3 taken 710 times.
104960 if(tempguy.family == eeWALK && tempguy.attributes[8] == e9tPOLSVOICE)
15090 {
15091 710 tempguy.moveflags |= move_can_waterwalk;
15092 710 }
15093 104960 }
15094
15095
2/2
✓ Branch 0 taken 89088 times.
✓ Branch 1 taken 107520 times.
196608 if (guyversion < 47)
15096 {
15097
4/4
✓ Branch 0 taken 1460 times.
✓ Branch 1 taken 106060 times.
✓ Branch 2 taken 876 times.
✓ Branch 3 taken 584 times.
107520 if (tempguy.family == eeDIG && tempguy.attributes[9]!=1)
15098 {
15099 584 tempguy.flags |= guy_ignore_kill_all;
15100 584 }
15101 107520 }
15102
15103
2/2
✓ Branch 0 taken 68608 times.
✓ Branch 1 taken 128000 times.
196608 if (guyversion < 49)
15104 {
15105
8/8
✓ Branch 0 taken 16638 times.
✓ Branch 1 taken 111362 times.
✓ Branch 2 taken 16157 times.
✓ Branch 3 taken 481 times.
✓ Branch 4 taken 15665 times.
✓ Branch 5 taken 492 times.
✓ Branch 6 taken 537 times.
✓ Branch 7 taken 15128 times.
128000 if (tempguy.family == eeWALK && (tempguy.attributes[6]==e7tPERMJINX || tempguy.attributes[6]==e7tTEMPJINX || tempguy.attributes[6]==e7tUNJINX)) //BUBBLE CHECK
15106 {
15107
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 722 times.
✓ Branch 2 taken 727 times.
✓ Branch 3 taken 61 times.
1510 switch (tempguy.attributes[7]) {
15108 case 0: //Sword
15109 722 tempguy.attributes[7] = e8tSWORD;
15110 722 break;
15111 case 1: //Item
15112 727 tempguy.attributes[7] = e8tITEM;
15113 727 break;
15114 case 2: //Both
15115 61 tempguy.attributes[7] = e8tSWORD|e8tITEM;
15116 61 break;
15117 default: //this can actually happen since Misc8 can be set to any number.
15118 tempguy.attributes[7] = 0;
15119 break;
15120 }
15121 1510 }
15122 128000 }
15123
15124 //these could possible be combined but rather be safe...
15125
2/2
✓ Branch 0 taken 68608 times.
✓ Branch 1 taken 128000 times.
196608 if (guyversion < 51) //reimport the firesfx, zoria ducked up.
15126 {
15127 128000 guy_update_firesfx(tempguy);
15128 128000 }
15129
2/2
✓ Branch 0 taken 128000 times.
✓ Branch 1 taken 68608 times.
196608 if (guyversion < 52)
15130 {
15131 128000 guy_update_weaponflags(tempguy);
15132 128000 }
15133 else
15134 {
15135
1/2
✓ Branch 0 taken 68608 times.
✗ Branch 1 not taken.
68608 if (!p_getc(&(tempguy.wunblockable), f))
15136 return qe_invalid;
15137
1/2
✓ Branch 0 taken 68608 times.
✗ Branch 1 not taken.
68608 if (!p_igetl(&(tempguy.wmoveflags), f))
15138 return qe_invalid;
15139
1/2
✓ Branch 0 taken 68608 times.
✗ Branch 1 not taken.
68608 if (!p_igetl(&(tempguy.weapoverrideFLAGS), f))
15140 return qe_invalid;
15141
1/2
✓ Branch 0 taken 68608 times.
✗ Branch 1 not taken.
68608 if (!p_igetl(&(tempguy.weap_tilew), f))
15142 return qe_invalid;
15143
1/2
✓ Branch 0 taken 68608 times.
✗ Branch 1 not taken.
68608 if (!p_igetl(&(tempguy.weap_tileh), f))
15144 return qe_invalid;
15145
1/2
✓ Branch 0 taken 68608 times.
✗ Branch 1 not taken.
68608 if (!p_igetl(&(tempguy.weap_hxsz), f))
15146 return qe_invalid;
15147
1/2
✓ Branch 0 taken 68608 times.
✗ Branch 1 not taken.
68608 if (!p_igetl(&(tempguy.weap_hysz), f))
15148 return qe_invalid;
15149
1/2
✓ Branch 0 taken 68608 times.
✗ Branch 1 not taken.
68608 if (!p_igetl(&(tempguy.weap_hzsz), f))
15150 return qe_invalid;
15151
1/2
✓ Branch 0 taken 68608 times.
✗ Branch 1 not taken.
68608 if (!p_igetl(&(tempguy.weap_hxofs), f))
15152 return qe_invalid;
15153
1/2
✓ Branch 0 taken 68608 times.
✗ Branch 1 not taken.
68608 if (!p_igetl(&(tempguy.weap_hyofs), f))
15154 return qe_invalid;
15155
1/2
✓ Branch 0 taken 68608 times.
✗ Branch 1 not taken.
68608 if (!p_igetl(&(tempguy.weap_xofs), f))
15156 return qe_invalid;
15157
1/2
✓ Branch 0 taken 68608 times.
✗ Branch 1 not taken.
68608 if (!p_igetl(&(tempguy.weap_yofs), f))
15158 return qe_invalid;
15159
1/2
✓ Branch 0 taken 68608 times.
✗ Branch 1 not taken.
68608 if (!p_igetl(&(tempguy.wstep), f))
15160 return qe_invalid;
15161
2/2
✓ Branch 0 taken 343040 times.
✓ Branch 1 taken 68608 times.
411648 for (int32_t q = 0; q < WPNSPR_MAX; ++q)
15162 {
15163
1/2
✓ Branch 0 taken 343040 times.
✗ Branch 1 not taken.
343040 if (!p_igetw(&(tempguy.burnsprs[q]), f))
15164 return qe_invalid;
15165
1/2
✓ Branch 0 taken 343040 times.
✗ Branch 1 not taken.
343040 if (!p_igetw(&(tempguy.light_rads[q]), f))
15166 return qe_invalid;
15167 343040 }
15168 }
15169
2/2
✓ Branch 0 taken 128000 times.
✓ Branch 1 taken 68608 times.
196608 if (guyversion < 53)
15170 {
15171 128000 guy_update_weaponspecialsfx(tempguy);
15172 128000 }
15173 else
15174 {
15175
1/2
✓ Branch 0 taken 68608 times.
✗ Branch 1 not taken.
68608 if (!p_getc(&(tempguy.specialsfx), f))
15176 return qe_invalid;
15177 }
15178
15179
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
15180 {
15181 tempguy.script = 0;
15182 for(int q = 0; q < 8; ++q)
15183 tempguy.initD[q] = 0;
15184 }
15185 196608 guysbuf[i] = tempguy;
15186 196608 }
15187 384 }
15188
15189 384 return 0;
15190 466 }
15191
15192 void update_guy_1(guydata *tempguy) // November 2009
15193 {
15194 bool doesntcount = false;
15195 tempguy->flags &= ~guy_weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15196
15197 switch(tempguy->family)
15198 {
15199 case 1: //eeWALK
15200 switch(tempguy->attributes[9])
15201 {
15202 case 0: //Stalfos
15203 if(tempguy->attributes[0]==1) // Fires four projectiles at once
15204 tempguy->attributes[0]=4;
15205
15206 break;
15207
15208 case 1: //Darknut
15209 goto darknuts;
15210 break;
15211 }
15212
15213 tempguy->attributes[9] = 0;
15214 break;
15215
15216 case 2: //eeSHOOT
15217 tempguy->family = eeWALK;
15218
15219 switch(tempguy->attributes[9])
15220 {
15221 case 0: //Octorok
15222 if(tempguy->attributes[0]==1||tempguy->attributes[0]==2)
15223 {
15224 tempguy->attributes[0]=e1tFIREOCTO;
15225 tempguy->attributes[1]=e2tFIREOCTO;
15226 }
15227 else tempguy->attributes[0] = 0;
15228
15229 tempguy->attributes[5]=tempguy->attributes[3];
15230 tempguy->attributes[3]=tempguy->attributes[2];
15231 tempguy->attributes[2]=0;
15232 break;
15233
15234 case 1: // Moblin
15235 tempguy->attributes[0] = 0;
15236 break;
15237
15238 case 2: //Lynel
15239 tempguy->attributes[5]=tempguy->attributes[0]+1;
15240 tempguy->attributes[0]=0;
15241 break;
15242
15243 case 3: //Stalfos 2
15244 if(tempguy->attributes[0]==1) // Fires four projectiles at once
15245 tempguy->attributes[0]=e1t4SHOTS;
15246 else tempguy->attributes[0] = 0;
15247
15248 break;
15249
15250 case 4: //Darknut 5
15251 darknuts:
15252 tempguy->defense[edefFIRE] = edIGNORE;
15253 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15254 tempguy->defense[edefHOOKSHOT] = 0;
15255 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15256 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15257
15258 if(tempguy->attributes[0]==1)
15259 tempguy->attributes[0]=2;
15260 else if(tempguy->attributes[0]==2)
15261 {
15262 tempguy->attributes[3]=tempguy->attributes[2];
15263 tempguy->attributes[2]=tempguy->attributes[1];
15264 tempguy->attributes[1]=e2tSPLIT;
15265 tempguy->attributes[0] = 0;
15266 }
15267 else tempguy->attributes[0] = 0;
15268
15269 tempguy->flags |= guy_shield_front;
15270
15271 if(!get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15272 tempguy->flags &= ~guy_bkshield;
15273 else
15274 tempguy->flags |= guy_bkshield;
15275
15276 break;
15277 }
15278
15279 tempguy->attributes[9] = 0;
15280 break;
15281
15282 /*
15283 case 9: //eeARMOS
15284 tempguy->family = eeWALK;
15285 break;
15286 */
15287 case 11: //eeGEL
15288 case 33: //eeGELTRIB
15289 if(tempguy->family==33)
15290 {
15291 tempguy->attributes[3] = 1;
15292
15293 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15294 tempguy->attributes[2] = tempguy->attributes[1];
15295
15296 tempguy->attributes[1] = e2tTRIBBLE;
15297 }
15298 else
15299 {
15300 tempguy->attributes[3] = 0;
15301 tempguy->attributes[2] = 0;
15302 tempguy->attributes[1] = 0;
15303 }
15304
15305 tempguy->family = eeWALK;
15306
15307 if(tempguy->attributes[0])
15308 {
15309 tempguy->attributes[0]=1;
15310 tempguy->weapon = ewFireTrail;
15311 }
15312
15313 break;
15314
15315 case 34: //eeZOLTRIB
15316 case 12: //eeZOL
15317 tempguy->attributes[3]=tempguy->attributes[2];
15318 tempguy->attributes[2]=tempguy->attributes[1];
15319 tempguy->family = eeWALK;
15320 tempguy->attributes[1]=e2tSPLITHIT;
15321
15322 if(tempguy->attributes[0])
15323 {
15324 tempguy->attributes[0]=1;
15325 tempguy->weapon = ewFireTrail;
15326 }
15327
15328 break;
15329
15330 case 13: //eeROPE
15331 tempguy->family = eeWALK;
15332 tempguy->attributes[8] = e9tROPE;
15333
15334 if(tempguy->attributes[0])
15335 {
15336 tempguy->attributes[3] = tempguy->attributes[2];
15337 tempguy->attributes[2] = tempguy->attributes[1];
15338 tempguy->attributes[1] = e2tBOMBCHU;
15339 }
15340
15341 tempguy->attributes[0] = 0;
15342 break;
15343
15344 case 14: //eeGORIYA
15345 tempguy->family = eeWALK;
15346
15347 if(tempguy->attributes[0]!=2) tempguy->attributes[0] = 0;
15348
15349 break;
15350
15351 case 17: //eeBUBBLE
15352 tempguy->family = eeWALK;
15353 tempguy->attributes[7] = tempguy->attributes[1];
15354 tempguy->attributes[6] = tempguy->attributes[0] + 1;
15355 tempguy->attributes[0] = tempguy->attributes[1] = 0;
15356
15357 //fallthrogh
15358 case eeTRAP:
15359 case eeROCK:
15360 doesntcount = true;
15361 break;
15362
15363 case 35: //eeVIRETRIB
15364 case 18: //eeVIRE
15365 tempguy->family = eeWALK;
15366 tempguy->attributes[3]=tempguy->attributes[2];
15367 tempguy->attributes[2]=tempguy->attributes[1];
15368 tempguy->attributes[1]=e2tSPLITHIT;
15369 tempguy->attributes[8]=e9tVIRE;
15370 break;
15371
15372 case 19: //eeLIKE
15373 tempguy->family = eeWALK;
15374 tempguy->attributes[6] = e7tEATITEMS;
15375 tempguy->attributes[7]=95;
15376 break;
15377
15378 case 20: //eePOLSV
15379 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15380 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15381 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15382 tempguy->defense[edefARROW] = ed1HKO;
15383 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15384 tempguy->family = eeWALK;
15385 tempguy->attributes[8] = e9tPOLSVOICE;
15386 tempguy->rate = 4;
15387 tempguy->homing = 32;
15388 tempguy->hrate = 10;
15389 tempguy->grumble = 0;
15390 break;
15391
15392 case eeWIZZ:
15393 if(tempguy->attributes[3])
15394 {
15395 for(int32_t i=0; i < edefLAST; i++)
15396 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15397 }
15398 else
15399 {
15400 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15401 tempguy->defense[edefMAGIC] = edCHINK;
15402 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15403 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15404 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15405 }
15406
15407 break;
15408
15409 case eePEAHAT:
15410 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15411
15412 if(!(tempguy->flags & guy_bhit))
15413 tempguy->defense[edefBRANG] = edSTUNONLY;
15414
15415 break;
15416
15417 case eeLEV:
15418 tempguy->defense[edefSTOMP] = edCHINK;
15419 break;
15420 }
15421
15422 // Old flags
15423 if(tempguy->flags & guy_superman)
15424 {
15425 for(int32_t i = 0; i < edefLAST; i++)
15426 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15427 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15428 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15429 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15430 }
15431
15432 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15433
15434 if(doesntcount)
15435 tempguy->flags |= (guy_doesnt_count);
15436 }
15437
15438 1186472 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
15439 {
15440 byte tempbyte, padding;
15441 int32_t extras, secretcombos;
15442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->valid),f))
15443 {
15444 return qe_invalid;
15445 }
15446
15447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->guy),f))
15448 return qe_invalid;
15449 1186472 temp_mapscr->guytile = -1; //signal to use default guy values
15450
2/2
✓ Branch 0 taken 1185873 times.
✓ Branch 1 taken 599 times.
1186472 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15451
4/4
✓ Branch 0 taken 599 times.
✓ Branch 1 taken 1185873 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 539 times.
1186472 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15452
15453
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15454 {
15455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
22176 if(!p_getc(&tempbyte,f))
15456 {
15457 return qe_invalid;
15458 }
15459
15460 22176 temp_mapscr->str=tempbyte;
15461 22176 }
15462 else
15463 {
15464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1164296 times.
1164296 if(!p_igetw(&(temp_mapscr->str),f))
15465 {
15466 return qe_invalid;
15467 }
15468 }
15469
15470
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->room),f))
15471 {
15472 return qe_invalid;
15473 }
15474
15475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->item),f))
15476 {
15477 return qe_invalid;
15478 }
15479
15480
3/6
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 657968 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15481 {
15482 528504 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15483 528504 }
15484 else
15485 {
15486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->hasitem),f))
15487 return qe_invalid;
15488 }
15489
15490
3/4
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1189192 if((Header->zelda_version < 0x192)||
15491
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
1164296 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15492 {
15493
1/2
✓ Branch 0 taken 22176 times.
✗ Branch 1 not taken.
22176 if(!p_getc(&tempbyte,f))
15494 {
15495 return qe_invalid;
15496 }
15497 22176 }
15498
15499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15500 {
15501 return qe_invalid;
15502 }
15503
15504
2/2
✓ Branch 0 taken 1161576 times.
✓ Branch 1 taken 24896 times.
1186472 if(Header->zelda_version < 0x193)
15505 {
15506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24896 times.
24896 if(!p_getc(&tempbyte,f))
15507 {
15508 return qe_invalid;
15509 }
15510 24896 }
15511
15512
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15513 {
15514
2/2
✓ Branch 0 taken 1973904 times.
✓ Branch 1 taken 657968 times.
2631872 for(int32_t i=1; i<4; i++)
15515 {
15516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973904 times.
1973904 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15517 {
15518 return qe_invalid;
15519 }
15520 1973904 }
15521 657968 }
15522 else
15523 {
15524 528504 temp_mapscr->tilewarptype[1]=0;
15525 528504 temp_mapscr->tilewarptype[2]=0;
15526 528504 temp_mapscr->tilewarptype[3]=0;
15527 }
15528
15529
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15530 {
15531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1164296 times.
1164296 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15532 {
15533 return qe_invalid;
15534 }
15535 1164296 }
15536
15537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15538 {
15539 return qe_invalid;
15540 }
15541
15542 1186472 temp_mapscr->warpreturnx[1]=0;
15543 1186472 temp_mapscr->warpreturnx[2]=0;
15544 1186472 temp_mapscr->warpreturnx[3]=0;
15545
15546
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15547 {
15548
2/2
✓ Branch 0 taken 1973904 times.
✓ Branch 1 taken 657968 times.
2631872 for(int32_t i=1; i<4; i++)
15549 {
15550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973904 times.
1973904 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15551 {
15552 return qe_invalid;
15553 }
15554 1973904 }
15555 657968 }
15556
15557
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15558 {
15559 return qe_invalid;
15560 }
15561
15562 1186472 temp_mapscr->warpreturny[1]=0;
15563 1186472 temp_mapscr->warpreturny[2]=0;
15564 1186472 temp_mapscr->warpreturny[3]=0;
15565
15566
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15567 {
15568
2/2
✓ Branch 0 taken 1973904 times.
✓ Branch 1 taken 657968 times.
2631872 for(int32_t i=1; i<4; i++)
15569 {
15570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973904 times.
1973904 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15571 {
15572 return qe_invalid;
15573 }
15574 1973904 }
15575
15576
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(version>=18)
15577 {
15578
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15579 {
15580 return qe_invalid;
15581 }
15582 657968 }
15583 else
15584 {
15585 byte temp;
15586
15587 if(!p_getc(&temp,f))
15588 {
15589 return qe_invalid;
15590 }
15591
15592 temp_mapscr->warpreturnc=temp<<8|temp;
15593 }
15594 657968 }
15595
15596
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->stairx),f))
15597
15598 {
15599 return qe_invalid;
15600 }
15601
15602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->stairy),f))
15603 {
15604 return qe_invalid;
15605 }
15606
15607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->itemx),f))
15608 {
15609 return qe_invalid;
15610 }
15611
15612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->itemy),f))
15613 {
15614 return qe_invalid;
15615 }
15616
15617
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version > 15) // February 2009
15618 {
15619
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_igetw(&(temp_mapscr->color),f))
15620 {
15621 return qe_invalid;
15622 }
15623 657968 }
15624 else
15625 {
15626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 528504 times.
528504 if(!p_getc(& tempbyte,f))
15627 {
15628 return qe_invalid;
15629 }
15630
15631 528504 temp_mapscr->color = (word) tempbyte;
15632 }
15633
15634
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->flags11),f))
15635 {
15636 return qe_invalid;
15637 }
15638
15639
2/2
✓ Branch 0 taken 4745888 times.
✓ Branch 1 taken 1186472 times.
5932360 for(int32_t k=0; k<4; k++)
15640 {
15641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4745888 times.
4745888 if(!p_getc(&(temp_mapscr->door[k]),f))
15642 {
15643 return qe_invalid;
15644
15645 }
15646 4745888 }
15647
15648
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
1186472 if(version <= 11)
15649 {
15650
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
15651 {
15652 return qe_invalid;
15653 }
15654
15655 528504 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15656
15657
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15658 {
15659 for(int32_t i=1; i<4; i++)
15660 {
15661 if(!p_getc(&(tempbyte),f))
15662 {
15663 return qe_invalid;
15664 }
15665
15666 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15667 }
15668 }
15669 else
15670 {
15671 528504 temp_mapscr->tilewarpdmap[1]=0;
15672 528504 temp_mapscr->tilewarpdmap[2]=0;
15673 528504 temp_mapscr->tilewarpdmap[3]=0;
15674 }
15675 528504 }
15676 else
15677 {
15678
2/2
✓ Branch 0 taken 2631872 times.
✓ Branch 1 taken 657968 times.
3289840 for(int32_t i=0; i<4; i++)
15679 {
15680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2631872 times.
2631872 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15681 {
15682 return qe_invalid;
15683 }
15684 2631872 }
15685 }
15686
15687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15688 {
15689 return qe_invalid;
15690 }
15691
15692
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15693 {
15694
2/2
✓ Branch 0 taken 1973904 times.
✓ Branch 1 taken 657968 times.
2631872 for(int32_t i=1; i<4; i++)
15695 {
15696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973904 times.
1973904 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15697 {
15698 return qe_invalid;
15699 }
15700 1973904 }
15701 657968 }
15702 else
15703 {
15704 528504 temp_mapscr->tilewarpscr[1]=0;
15705 528504 temp_mapscr->tilewarpscr[2]=0;
15706 528504 temp_mapscr->tilewarpscr[3]=0;
15707 }
15708
15709
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version >= 15)
15710 {
15711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15712 {
15713 return qe_invalid;
15714 }
15715 657968 }
15716 else
15717 {
15718 528504 temp_mapscr->tilewarpoverlayflags=0;
15719 }
15720
15721
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->exitdir),f))
15722 {
15723 return qe_invalid;
15724 }
15725
15726
2/2
✓ Branch 0 taken 1161576 times.
✓ Branch 1 taken 24896 times.
1186472 if(Header->zelda_version < 0x193)
15727 {
15728
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if(!p_getc(&tempbyte,f))
15729 {
15730 return qe_invalid;
15731 }
15732
15733 24896 }
15734
15735
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1183752 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15736 {
15737 if(!p_getc(&padding,f))
15738 {
15739 return qe_invalid;
15740 }
15741 }
15742
15743
2/2
✓ Branch 0 taken 11864720 times.
✓ Branch 1 taken 1186472 times.
13051192 for(int32_t k=0; k<10; k++)
15744 {
15745
5/6
✓ Branch 0 taken 11642960 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11615760 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11864720 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15746 {
15747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221760 times.
221760 if(!p_getc(&tempbyte,f))
15748 {
15749 return qe_invalid;
15750 }
15751
15752 221760 temp_mapscr->enemy[k]=tempbyte;
15753 221760 }
15754 else
15755 {
15756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11642960 times.
11642960 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
15757 {
15758 return qe_invalid;
15759 }
15760 }
15761
15762
5/6
✓ Branch 0 taken 11642960 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11615760 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11864720 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15763 {
15764 //using enumerations here is dangerous
15765 //very easy to break old quests -DD
15766
2/2
✓ Branch 0 taken 1342 times.
✓ Branch 1 taken 220418 times.
221760 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15767 {
15768 1342 temp_mapscr->enemy[k]+=5;
15769 1342 }
15770
2/2
✓ Branch 0 taken 220324 times.
✓ Branch 1 taken 94 times.
220418 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15771 {
15772 94 temp_mapscr->enemy[k]+=1;
15773 94 }
15774 221760 }
15775
15776
2/2
✓ Branch 0 taken 6579680 times.
✓ Branch 1 taken 5285040 times.
11864720 if(version < 9)
15777 {
15778
2/2
✓ Branch 0 taken 5009135 times.
✓ Branch 1 taken 275905 times.
5285040 if(temp_mapscr->enemy[k]>0)
15779 {
15780 275905 temp_mapscr->enemy[k]+=10;
15781 275905 }
15782 5285040 }
15783 //don't read in any invalid data
15784
2/2
✓ Branch 0 taken 11864270 times.
✓ Branch 1 taken 450 times.
11864720 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15785 {
15786 450 al_trace("Tried to read an invalid enemy ID (%d) for enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15787 450 temp_mapscr->enemy[k] = 0;
15788 450 }
15789 11864720 }
15790
15791
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->pattern),f))
15792 {
15793 return qe_invalid;
15794 }
15795
15796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
15797 {
15798 return qe_invalid;
15799 }
15800
15801
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15802 {
15803
2/2
✓ Branch 0 taken 1973904 times.
✓ Branch 1 taken 657968 times.
2631872 for(int32_t i=1; i<4; i++)
15804 {
15805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973904 times.
1973904 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
15806 {
15807 return qe_invalid;
15808 }
15809 1973904 }
15810 657968 }
15811 else
15812 {
15813 528504 temp_mapscr->sidewarptype[1]=0;
15814 528504 temp_mapscr->sidewarptype[2]=0;
15815 528504 temp_mapscr->sidewarptype[3]=0;
15816 }
15817
15818
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version >= 15)
15819 {
15820
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
15821 {
15822 return qe_invalid;
15823 }
15824 657968 }
15825 else
15826 {
15827 528504 temp_mapscr->sidewarpoverlayflags=0;
15828 }
15829
15830
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->warparrivalx),f))
15831 {
15832 return qe_invalid;
15833 }
15834
15835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->warparrivaly),f))
15836 {
15837 return qe_invalid;
15838 }
15839
15840
2/2
✓ Branch 0 taken 4745888 times.
✓ Branch 1 taken 1186472 times.
5932360 for(int32_t k=0; k<4; k++)
15841 {
15842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4745888 times.
4745888 if(!p_getc(&(temp_mapscr->path[k]),f))
15843 {
15844 return qe_invalid;
15845 }
15846 4745888 }
15847
15848
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
15849 {
15850 return qe_invalid;
15851 }
15852
15853
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15854 {
15855
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 1973904 times.
2631872 for(int32_t i=1; i<4; i++)
15856 {
15857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973904 times.
1973904 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
15858 {
15859 return qe_invalid;
15860 }
15861 1973904 }
15862 657968 }
15863 else
15864 {
15865 528504 temp_mapscr->sidewarpscr[1]=0;
15866 528504 temp_mapscr->sidewarpscr[2]=0;
15867 528504 temp_mapscr->sidewarpscr[3]=0;
15868 }
15869
15870
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
1186472 if(version <= 11)
15871 {
15872
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
15873 {
15874 return qe_invalid;
15875 }
15876
15877 528504 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
15878
15879
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15880 {
15881 for(int32_t i=1; i<4; i++)
15882 {
15883 if(!p_getc(&(tempbyte),f))
15884 {
15885 return qe_invalid;
15886 }
15887
15888 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
15889 }
15890 }
15891 else
15892 {
15893 528504 temp_mapscr->sidewarpdmap[1]=0;
15894 528504 temp_mapscr->sidewarpdmap[2]=0;
15895 528504 temp_mapscr->sidewarpdmap[3]=0;
15896 }
15897 528504 }
15898 else
15899 {
15900
2/2
✓ Branch 0 taken 2631872 times.
✓ Branch 1 taken 657968 times.
3289840 for(int32_t i=0; i<4; i++)
15901 {
15902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2631872 times.
2631872 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
15903 {
15904 return qe_invalid;
15905 }
15906 2631872 }
15907 }
15908
15909
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15910 {
15911
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
15912 {
15913 return qe_invalid;
15914 }
15915 657968 }
15916 528504 else temp_mapscr->sidewarpindex = 0;
15917
15918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_igetw(&(temp_mapscr->undercombo),f))
15919 {
15920 return qe_invalid;
15921 }
15922
15923
2/2
✓ Branch 0 taken 1161576 times.
✓ Branch 1 taken 24896 times.
1186472 if(Header->zelda_version < 0x193)
15924 {
15925
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if (!p_getc(&old_combo_pages[scrind], f))
15926 {
15927 return qe_invalid;
15928 }
15929 24896 }
15930
15931
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
15932 {
15933 return qe_invalid;
15934 }
15935
15936
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_igetw(&(temp_mapscr->catchall),f))
15937 {
15938 return qe_invalid;
15939 }
15940
15941
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->flags),f))
15942 {
15943 return qe_invalid;
15944 }
15945
15946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->flags2),f))
15947 {
15948 return qe_invalid;
15949 }
15950
15951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->flags3),f))
15952 {
15953 return qe_invalid;
15954 }
15955
15956
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
15957 //if (version>2)
15958 {
15959
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->flags4),f))
15960 {
15961 return qe_invalid;
15962 }
15963 657968 }
15964
15965
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15966 {
15967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->flags5),f))
15968 {
15969 return qe_invalid;
15970 }
15971
15972
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_igetw(&(temp_mapscr->noreset),f))
15973 {
15974 return qe_invalid;
15975 }
15976
15977
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_igetw(&(temp_mapscr->nocarry),f))
15978 {
15979 return qe_invalid;
15980 }
15981
15982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(temp_mapscr->flags5&32)
15983 {
15984 temp_mapscr->flags5 &= ~32;
15985 temp_mapscr->noreset |= 48;
15986 }
15987
15988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(version<8)
15989 {
15990 if(temp_mapscr->noreset&1)
15991 {
15992 temp_mapscr->noreset|=8192;
15993 }
15994
15995 if(temp_mapscr->nocarry&1)
15996 {
15997 temp_mapscr->nocarry|=8192;
15998 temp_mapscr->nocarry&=~1;
15999 }
16000 }
16001 657968 }
16002 else
16003 {
16004 528504 temp_mapscr->flags5 = 0;
16005 528504 temp_mapscr->noreset = 0;
16006 528504 temp_mapscr->nocarry = 0;
16007 }
16008
16009
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16010 {
16011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->flags6),f))
16012 {
16013 return qe_invalid;
16014 }
16015 657968 }
16016
16017
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version>5)
16018 {
16019
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->flags7),f))
16020 {
16021 return qe_invalid;
16022 }
16023
16024
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->flags8),f))
16025 {
16026 return qe_invalid;
16027 }
16028
16029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->flags9),f))
16030 {
16031 return qe_invalid;
16032 }
16033
16034
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->flags10),f))
16035 {
16036 return qe_invalid;
16037 }
16038
16039
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->csensitive),f))
16040 {
16041 return qe_invalid;
16042 }
16043 657968 }
16044 else
16045 {
16046 528504 temp_mapscr->csensitive=1;
16047 }
16048
16049
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
1186472 if(version<14) // August 2007: screen SFX added
16050 {
16051
2/2
✓ Branch 0 taken 527510 times.
✓ Branch 1 taken 994 times.
528504 if(temp_mapscr->flags&8) //fROAR
16052 {
16053 994 temp_mapscr->bosssfx=
16054
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 853 times.
994 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16055 853 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16056 WAV_ROAR;
16057 994 }
16058
16059
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 528334 times.
528504 if(temp_mapscr->flags&128) //fSEA_SFX
16060 {
16061 170 temp_mapscr->oceansfx=WAV_SEA;
16062 170 }
16063
16064 528504 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16065 ? 0 : WAV_SECRET;
16066
16067 528504 temp_mapscr->flags3 &= ~66; //64|2
16068 528504 temp_mapscr->flags2 &= ~32;
16069 528504 temp_mapscr->flags &= ~136; // 128|8
16070 528504 }
16071 else
16072 {
16073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->oceansfx),f))
16074 {
16075 return qe_invalid;
16076 }
16077
16078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->bosssfx),f))
16079 {
16080 return qe_invalid;
16081 }
16082
16083
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->secretsfx),f))
16084 {
16085 return qe_invalid;
16086 }
16087 }
16088
16089
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
1186472 if(version<15) // October 2007: another SFX
16090 {
16091 528504 temp_mapscr->holdupsfx=WAV_PICKUP;
16092 528504 }
16093 else
16094 {
16095
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->holdupsfx),f))
16096 {
16097 return qe_invalid;
16098 }
16099 }
16100
16101
16102
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16103 {
16104
2/2
✓ Branch 0 taken 6985776 times.
✓ Branch 1 taken 1164296 times.
8150072 for(int32_t k=0; k<6; k++)
16105 {
16106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6985776 times.
6985776 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16107 {
16108 return qe_invalid;
16109 }
16110 6985776 }
16111
16112
2/2
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 6985776 times.
8150072 for(int32_t k=0; k<6; k++)
16113 {
16114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6985776 times.
6985776 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16115 {
16116 return qe_invalid;
16117 }
16118 6985776 }
16119 1164296 }
16120
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22176 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16121 {
16122 if(!p_getc(&(temp_mapscr->layermap[2]),f))
16123 {
16124 return qe_invalid;
16125 }
16126
16127 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
16128 {
16129 return qe_invalid;
16130 }
16131
16132 if(!p_getc(&(temp_mapscr->layermap[4]),f))
16133 {
16134 return qe_invalid;
16135 }
16136
16137 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
16138
16139 {
16140 return qe_invalid;
16141 }
16142 }
16143
16144
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1183752 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1186472 if((Header->zelda_version == 0x192)&&(Header->build>149))
16145 {
16146
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16147 {
16148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxsize
16149 {
16150 return qe_invalid;
16151 }
16152 16320 }
16153
16154
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16155 {
16156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxspeed
16157 {
16158 return qe_invalid;
16159 }
16160 16320 }
16161
16162
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16163 {
16164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxdelay
16165 {
16166 return qe_invalid;
16167 }
16168 16320 }
16169
16170
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16171 {
16172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerysize
16173 {
16174 return qe_invalid;
16175 }
16176 16320 }
16177
16178
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16179 {
16180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layeryspeed
16181 {
16182 return qe_invalid;
16183 }
16184 16320 }
16185
16186
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 16320 times.
19040 for(int32_t k=0; k<6; k++)
16187 {
16188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerydelay
16189 {
16190 return qe_invalid;
16191 }
16192 16320 }
16193 2720 }
16194
16195
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16196 {
16197
2/2
✓ Branch 0 taken 6985776 times.
✓ Branch 1 taken 1164296 times.
8150072 for(int32_t k=0; k<6; k++)
16198 {
16199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6985776 times.
6985776 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16200 {
16201 return qe_invalid;
16202 }
16203 6985776 }
16204 1164296 }
16205
16206
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16207 {
16208
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1164296 if((Header->zelda_version == 0x192)&&(Header->build>153))
16209 {
16210
1/2
✓ Branch 0 taken 2720 times.
✗ Branch 1 not taken.
2720 if(!p_getc(&padding,f))
16211 {
16212 return qe_invalid;
16213 }
16214 2720 }
16215
16216
1/2
✓ Branch 0 taken 1164296 times.
✗ Branch 1 not taken.
1164296 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16217 {
16218 return qe_invalid;
16219 }
16220 1164296 }
16221
16222
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16223 {
16224 22176 extras=15;
16225 22176 }
16226
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1164296 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16227 {
16228 extras=11;
16229 }
16230
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
1164296 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16231 {
16232 extras=32;
16233 }
16234
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1164296 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16235 {
16236 extras=64;
16237 }
16238
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
1164296 else if(Header->zelda_version < 0x193)
16239 {
16240 2720 extras=62;
16241 2720 }
16242 else
16243
16244 {
16245 1161576 extras=0;
16246 }
16247
16248
2/2
✓ Branch 0 taken 501280 times.
✓ Branch 1 taken 1186472 times.
1687752 for(int32_t k=0; k<extras; k++)
16249 {
16250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 501280 times.
501280 if(!p_getc(&tempbyte,f)) //extra[k]
16251 {
16252 return qe_invalid;
16253 }
16254 501280 }
16255
16256
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16257 //if (version>3)
16258 {
16259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->nextmap),f))
16260 {
16261 return qe_invalid;
16262 }
16263
16264
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->nextscr),f))
16265 {
16266 return qe_invalid;
16267 }
16268 657968 }
16269 else
16270 {
16271 528504 temp_mapscr->nextmap=0;
16272 528504 temp_mapscr->nextscr=0;
16273 }
16274
16275
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16276 {
16277 22176 secretcombos=20;
16278 22176 }
16279
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1164296 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16280 {
16281 secretcombos=256;
16282 }
16283 else
16284 {
16285 1164296 secretcombos=128;
16286 }
16287
16288
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16289 {
16290
2/2
✓ Branch 0 taken 443520 times.
✓ Branch 1 taken 22176 times.
465696 for(int32_t k=0; k<secretcombos; k++)
16291 {
16292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(!p_getc(&tempbyte,f))
16293 {
16294 return qe_invalid;
16295 }
16296
16297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(k<128)
16298 {
16299 443520 temp_mapscr->secretcombo[k]=tempbyte;
16300 443520 }
16301 443520 }
16302 22176 }
16303 else
16304 {
16305
2/2
✓ Branch 0 taken 149029888 times.
✓ Branch 1 taken 1164296 times.
150194184 for(int32_t k=0; k<128; k++)
16306 {
16307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149029888 times.
149029888 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16308 {
16309 return qe_invalid;
16310 }
16311
16312 149029888 }
16313 }
16314
16315
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16316 {
16317
2/2
✓ Branch 0 taken 149029888 times.
✓ Branch 1 taken 1164296 times.
150194184 for(int32_t k=0; k<128; k++)
16318 {
16319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149029888 times.
149029888 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16320 {
16321 return qe_invalid;
16322 }
16323 149029888 }
16324
16325
2/2
✓ Branch 0 taken 149029888 times.
✓ Branch 1 taken 1164296 times.
150194184 for(int32_t k=0; k<128; k++)
16326 {
16327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149029888 times.
149029888 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16328 {
16329 return qe_invalid;
16330 }
16331 149029888 }
16332 1164296 }
16333
16334
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1183752 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16335 {
16336 if(!p_getc(&padding,f))
16337 {
16338 return qe_invalid;
16339 }
16340 }
16341
16342
2/2
✓ Branch 0 taken 208819072 times.
✓ Branch 1 taken 1186472 times.
210005544 for(int32_t k=0; k<176; k++)
16343 {
16344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208819072 times.
208819072 if(!p_igetw(&(temp_mapscr->data[k]),f))
16345 {
16346 return qe_invalid;
16347 }
16348 208819072 }
16349
16350
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1183752 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16351 {
16352 if(!p_getc(&padding,f))
16353 {
16354 return qe_invalid;
16355 }
16356
16357 if(!p_getc(&padding,f))
16358 {
16359 return qe_invalid;
16360 }
16361 }
16362
16363
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16364 {
16365
2/2
✓ Branch 0 taken 204916096 times.
✓ Branch 1 taken 1164296 times.
206080392 for(int32_t k=0; k<176; k++)
16366 {
16367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204916096 times.
204916096 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16368 {
16369 return qe_invalid;
16370 }
16371
16372
3/4
✓ Branch 0 taken 478720 times.
✓ Branch 1 taken 204437376 times.
✓ Branch 2 taken 478720 times.
✗ Branch 3 not taken.
204916096 if((Header->zelda_version == 0x192)&&(Header->build<24))
16373 {
16374 if(!p_getc(&tempbyte,f))
16375 {
16376 return qe_invalid;
16377 }
16378
16379 if(!p_getc(&tempbyte,f))
16380 {
16381 return qe_invalid;
16382 }
16383
16384 if(!p_getc(&tempbyte,f))
16385 {
16386 return qe_invalid;
16387 }
16388 }
16389 204916096 }
16390 1164296 }
16391
16392
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16393 {
16394
2/2
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 204916096 times.
206080392 for(int32_t k=0; k<176; k++)
16395 {
16396
16397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204916096 times.
204916096 if(!p_getc(&(temp_mapscr->cset[k]),f))
16398 {
16399 return qe_invalid;
16400 }
16401 204916096 }
16402 1164296 }
16403
16404
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16405 {
16406 22176 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16407 22176 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(old_combo_pages[scrind]<<8);
16408 22176 }
16409
16410
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16411 {
16412 22176 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16413 22176 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16414 22176 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16415 22176 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16416 22176 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16417 22176 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16418 22176 }
16419
16420
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16421 {
16422
2/2
✓ Branch 0 taken 3902976 times.
✓ Branch 1 taken 22176 times.
3925152 for(int32_t k=0; k<176; k++)
16423 {
16424
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version == 0x192)&&(Header->build>149))
16425 {
16426 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16427 {
16428 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16429 }
16430 }
16431 else
16432 {
16433
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version < 0x192)||
16434 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16435 {
16436 3902976 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16437 3902976 }
16438
16439 3902976 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16440 }
16441
16442 3902976 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(old_combo_pages[scrind]<<8);
16443 3902976 }
16444 22176 }
16445
16446 /*if(version>12)
16447 {
16448 if(!p_getc(&(temp_mapscr->scrWidth),f))
16449 {
16450 return qe_invalid;
16451 }
16452 if(!p_getc(&(temp_mapscr->scrHeight),f))
16453 {
16454 return qe_invalid;
16455 }
16456 }*/
16457
16458
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version>4)
16459 {
16460
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16461 {
16462 return qe_invalid;
16463 }
16464 657968 }
16465 else
16466 {
16467 528504 temp_mapscr->screen_midi = -1;
16468 }
16469
16470
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version>=17)
16471 {
16472
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->lens_layer),f))
16473 {
16474 return qe_invalid;
16475 }
16476 657968 }
16477 else
16478 {
16479 528504 temp_mapscr->lens_layer = llNORMAL;
16480 }
16481
16482
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
1186472 if(version>6)
16483 {
16484 dword bits;
16485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_igetl(&bits,f))
16486 {
16487 return qe_invalid;
16488 }
16489
16490 int32_t m;
16491 float tempfloat;
16492 word tempw;
16493 657968 temp_mapscr->ffcCountMarkDirty();
16494 657968 temp_mapscr->ffcs.clear();
16495 657968 temp_mapscr->resizeFFC(std::bit_width(bits));
16496
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 21054976 times.
21712944 for(m=0; m<32; m++)
16497 {
16498
2/2
✓ Branch 0 taken 20778977 times.
✓ Branch 1 taken 275999 times.
21054976 if((bits>>m)&1)
16499 {
16500 275999 ffcdata& tempffc = temp_mapscr->ffcs[m];
16501
1/2
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
275999 if(!p_igetw(&tempw,f))
16502 {
16503 return qe_invalid;
16504 }
16505 275999 tempffc.data = tempw;
16506
16507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_getc(&(tempffc.cset),f))
16508 {
16509 return qe_invalid;
16510 }
16511
16512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetw(&(tempffc.delay),f))
16513 {
16514 return qe_invalid;
16515 }
16516
16517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(version < 9)
16518 {
16519 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16520 {
16521 return qe_invalid;
16522 }
16523
16524 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16525
16526 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16527 {
16528 return qe_invalid;
16529 }
16530
16531 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16532
16533 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16534 {
16535 return qe_invalid;
16536 }
16537
16538 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16539
16540 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16541 {
16542 return qe_invalid;
16543 }
16544
16545 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16546
16547 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16548 {
16549 return qe_invalid;
16550 }
16551
16552 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16553
16554 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16555 {
16556 return qe_invalid;
16557 }
16558
16559 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16560 }
16561 else
16562 {
16563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetzf(&(tempffc.x),f))
16564 {
16565 return qe_invalid;
16566 }
16567
16568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetzf(&(tempffc.y),f))
16569 {
16570 return qe_invalid;
16571 }
16572
16573
1/2
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
275999 if(!p_igetzf(&(tempffc.vx),f))
16574 {
16575 return qe_invalid;
16576 }
16577
16578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetzf(&(tempffc.vy),f))
16579 {
16580 return qe_invalid;
16581 }
16582
16583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetzf(&(tempffc.ax),f))
16584 {
16585 return qe_invalid;
16586 }
16587
16588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetzf(&(tempffc.ay),f))
16589 {
16590 return qe_invalid;
16591 }
16592 }
16593
16594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_getc(&(tempffc.link),f))
16595 {
16596 return qe_invalid;
16597 }
16598
16599
1/2
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
275999 if(version>7)
16600 {
16601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_getc(&tempbyte,f))
16602 {
16603 return qe_invalid;
16604 }
16605
16606 275999 tempffc.hit_width = (tempbyte&0x3F)+1;
16607 275999 tempffc.txsz = (tempbyte>>6)+1;
16608
16609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_getc(&tempbyte,f))
16610 {
16611 return qe_invalid;
16612 }
16613
16614 275999 tempffc.hit_height = (tempbyte&0x3F)+1;
16615 275999 tempffc.tysz = (tempbyte>>6)+1;
16616
16617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.flags),f))
16618 {
16619 return qe_invalid;
16620 }
16621 275999 }
16622 else
16623 {
16624 tempffc.hit_width=16;
16625 tempffc.hit_height=16;
16626 tempffc.txsz=1;
16627 tempffc.tysz=1;
16628 tempffc.flags=ffc_none;
16629 }
16630
16631 275999 tempffc.updateSolid();
16632
16633
16634
4/6
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 269995 times.
✓ Branch 3 taken 6004 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 269995 times.
275999 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16635 {
16636 tempffc.flags|=ffc_ignoreholdup;
16637 }
16638
16639
1/2
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
275999 if(version>9)
16640 {
16641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetw(&(tempffc.script),f))
16642 {
16643 return qe_invalid;
16644 }
16645 275999 }
16646 else
16647 {
16648 tempffc.script=0;
16649 }
16650
16651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(version>10)
16652 {
16653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[0]),f))
16654 {
16655 return qe_invalid;
16656 }
16657
16658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[1]),f))
16659 {
16660 return qe_invalid;
16661 }
16662
16663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[2]),f))
16664 {
16665 return qe_invalid;
16666 }
16667
16668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[3]),f))
16669 {
16670 return qe_invalid;
16671 }
16672
16673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[4]),f))
16674 {
16675 return qe_invalid;
16676 }
16677
16678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[5]),f))
16679 {
16680 return qe_invalid;
16681 }
16682
16683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[6]),f))
16684 {
16685 return qe_invalid;
16686 }
16687
16688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[7]),f))
16689 {
16690 return qe_invalid;
16691 }
16692
16693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_getc(&(tempbyte),f))
16694 {
16695 return qe_invalid;
16696 }
16697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_getc(&(tempbyte),f))
16698 {
16699 return qe_invalid;
16700 }
16701 275999 }
16702
16703
1/2
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
275999 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
16704 {
16705 tempffc.script = 0;
16706 for(int q = 0; q < 8; ++q)
16707 tempffc.initd[q] = 0;
16708 }
16709
1/2
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
275999 if(version <= 11)
16710 {
16711 fixffcs=true;
16712 }
16713 275999 }
16714 21054976 }
16715
16716 657968 temp_mapscr->shinkToFitFFCs();
16717 657968 }
16718
16719
16720 //add in the new whistle flags
16721
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version<13)
16722 {
16723
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 528380 times.
528504 if(temp_mapscr->flags & fWHISTLE)
16724 {
16725 124 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16726 124 }
16727 528504 }
16728
16729 //2.55 starts here
16730
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1186472 if ( version >= 19 && Header->zelda_version > 0x253 )
16731 {
16732 // mapscr fields that were never used, so are now removed:
16733 // int32_t npcstrings[10];
16734 // int16_t new_items[10];
16735 // int16_t new_item_x[10];
16736 // int16_t new_item_y[10];
16737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if (pack_fseek(f, 100))
16738 {
16739 return qe_invalid;
16740 }
16741 34408 }
16742
16743
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1186472 if ( version >= 20 && Header->zelda_version > 0x253 )
16744 {
16745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_igetw(&(temp_mapscr->script),f))
16746 {
16747 return qe_invalid;
16748 }
16749
2/2
✓ Branch 0 taken 275264 times.
✓ Branch 1 taken 34408 times.
309672 for ( int32_t q = 0; q < 8; q++)
16750 {
16751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275264 times.
275264 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16752 {
16753 return qe_invalid;
16754 }
16755 275264 }
16756 34408 }
16757
2/2
✓ Branch 0 taken 1152064 times.
✓ Branch 1 taken 34408 times.
1186472 if ( version < 20 )
16758 {
16759 1152064 temp_mapscr->script = 0;
16760
2/2
✓ Branch 0 taken 9216512 times.
✓ Branch 1 taken 1152064 times.
10368576 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16761 1152064 }
16762
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1186472 if ( version >= 21 && Header->zelda_version > 0x253 )
16763 {
16764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_getc(&(temp_mapscr->preloadscript),f))
16765 {
16766 return qe_invalid;
16767 }
16768 34408 }
16769
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152064 times.
1186472 if ( version < 21 )
16770 {
16771 1152064 temp_mapscr->preloadscript = 0;
16772 1152064 }
16773
16774
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1186472 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16775 {
16776
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidelayers ),f))
16777 {
16778 return qe_invalid;
16779 }
16780
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
16781 {
16782 return qe_invalid;
16783 }
16784 34408 }
16785
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152064 times.
1186472 if ( version < 22 )
16786 {
16787 1152064 temp_mapscr->hidelayers = 0;
16788 1152064 temp_mapscr->hidescriptlayers = 0;
16789 1152064 }
16790
16791 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16792 //May be any version before 2.11. -Z
16793 /* --not the roar, the HIT SFX
16794 if ( Header->zelda_version <= 0x210 )
16795 {
16796 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16797 {
16798 temp_mapscr->bosssfx = WAV_ROAR;
16799 }
16800 }
16801 */
16802
2/2
✓ Branch 0 taken 4745888 times.
✓ Branch 1 taken 1186472 times.
5932360 for(int32_t k=0; k<4; k++)
16803 {
16804
1/2
✓ Branch 0 taken 4745888 times.
✗ Branch 1 not taken.
4745888 if(temp_mapscr->door[k] == dNONE)
16805 temp_mapscr->door[k] = dWALL;
16806 4745888 }
16807
16808 1186472 return 0;
16809 1186472 }
16810 1382312 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
16811 {
16812
2/2
✓ Branch 0 taken 1186472 times.
✓ Branch 1 taken 195840 times.
1382312 if(version < 23)
16813 {
16814 1186472 auto ret = readmapscreen_old(f,Header,temp_mapscr,version,scrind);
16815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(ret) return ret;
16816 1186472 }
16817 else
16818 {
16819
1/2
✓ Branch 0 taken 195840 times.
✗ Branch 1 not taken.
195840 if(!p_getc(&(temp_mapscr->valid),f))
16820 return qe_invalid;
16821
2/2
✓ Branch 0 taken 103458 times.
✓ Branch 1 taken 92382 times.
195840 if(!(temp_mapscr->valid & mVALID))
16822 {
16823 92382 int map = scrind/MAPSCRS;
16824 92382 int screen = scrind%MAPSCRS;
16825
4/6
✓ Branch 0 taken 85280 times.
✓ Branch 1 taken 7102 times.
✓ Branch 2 taken 85280 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 85280 times.
92382 if(version > 25 && scrind > -1 && (map*6+5) < map_autolayers.size())
16826 {
16827 //Empty screen, apply autolayers
16828
2/2
✓ Branch 0 taken 511680 times.
✓ Branch 1 taken 85280 times.
596960 for(int q = 0; q < 6; ++q)
16829 {
16830 511680 auto layermap = map_autolayers[map*6+q];
16831 511680 temp_mapscr->layermap[q] = layermap;
16832
2/2
✓ Branch 0 taken 496524 times.
✓ Branch 1 taken 15156 times.
511680 if(layermap)
16833 15156 temp_mapscr->layerscreen[q] = screen;
16834 511680 }
16835 85280 }
16836 92382 return 0;
16837 }
16838 uint32_t scr_has_flags;
16839
1/2
✓ Branch 0 taken 103458 times.
✗ Branch 1 not taken.
103458 if(!p_igetl(&scr_has_flags,f))
16840 return qe_invalid;
16841
16842
2/2
✓ Branch 0 taken 10458 times.
✓ Branch 1 taken 93000 times.
103458 if(scr_has_flags & SCRHAS_ROOMDATA)
16843 {
16844
1/2
✓ Branch 0 taken 93000 times.
✗ Branch 1 not taken.
93000 if(!p_getc(&(temp_mapscr->guy),f))
16845 return qe_invalid;
16846
2/2
✓ Branch 0 taken 92880 times.
✓ Branch 1 taken 120 times.
93000 if(version > 26)
16847 {
16848
1/2
✓ Branch 0 taken 92880 times.
✗ Branch 1 not taken.
92880 if(!p_igetl(&(temp_mapscr->guytile),f))
16849 return qe_invalid;
16850
1/2
✓ Branch 0 taken 92880 times.
✗ Branch 1 not taken.
92880 if(!p_getc(&(temp_mapscr->guycs),f))
16851 return qe_invalid;
16852
1/2
✓ Branch 0 taken 92880 times.
✗ Branch 1 not taken.
92880 if(!p_igetw(&(temp_mapscr->roomflags),f))
16853 return qe_invalid;
16854 92880 }
16855 else
16856 {
16857 120 temp_mapscr->guytile = -1; //signal to use default guy values
16858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
16859
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
120 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
16860 }
16861
1/2
✓ Branch 0 taken 93000 times.
✗ Branch 1 not taken.
93000 if(!p_igetw(&(temp_mapscr->str),f))
16862 return qe_invalid;
16863
1/2
✓ Branch 0 taken 93000 times.
✗ Branch 1 not taken.
93000 if(!p_getc(&(temp_mapscr->room),f))
16864 return qe_invalid;
16865
1/2
✓ Branch 0 taken 93000 times.
✗ Branch 1 not taken.
93000 if(!p_igetw(&(temp_mapscr->catchall),f))
16866 return qe_invalid;
16867 93000 }
16868
2/2
✓ Branch 0 taken 101134 times.
✓ Branch 1 taken 2324 times.
103458 if(scr_has_flags & SCRHAS_ITEM)
16869 {
16870
1/2
✓ Branch 0 taken 2324 times.
✗ Branch 1 not taken.
2324 if(!p_getc(&(temp_mapscr->item),f))
16871 return qe_invalid;
16872
1/2
✓ Branch 0 taken 2324 times.
✗ Branch 1 not taken.
2324 if(!p_getc(&(temp_mapscr->hasitem),f))
16873 return qe_invalid;
16874
1/2
✓ Branch 0 taken 2324 times.
✗ Branch 1 not taken.
2324 if(!p_getc(&(temp_mapscr->itemx),f))
16875 return qe_invalid;
16876
1/2
✓ Branch 0 taken 2324 times.
✗ Branch 1 not taken.
2324 if(!p_getc(&(temp_mapscr->itemy),f))
16877 return qe_invalid;
16878 2324 }
16879
2/2
✓ Branch 0 taken 92847 times.
✓ Branch 1 taken 10611 times.
103458 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
16880 {
16881
1/2
✓ Branch 0 taken 10611 times.
✗ Branch 1 not taken.
10611 if(!p_igetw(&temp_mapscr->warpreturnc,f))
16882 return qe_invalid;
16883 10611 }
16884
2/2
✓ Branch 0 taken 100997 times.
✓ Branch 1 taken 2461 times.
103458 if(scr_has_flags & SCRHAS_TWARP)
16885 {
16886
2/2
✓ Branch 0 taken 9844 times.
✓ Branch 1 taken 2461 times.
12305 for(int32_t i=0; i<4; i++)
16887 {
16888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9844 times.
9844 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
16889 return qe_invalid;
16890 9844 }
16891
2/2
✓ Branch 0 taken 9844 times.
✓ Branch 1 taken 2461 times.
12305 for(int32_t i=0; i<4; i++)
16892 {
16893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9844 times.
9844 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
16894 return qe_invalid;
16895 9844 }
16896
2/2
✓ Branch 0 taken 9844 times.
✓ Branch 1 taken 2461 times.
12305 for(int32_t i=0; i<4; i++)
16897 {
16898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9844 times.
9844 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
16899 return qe_invalid;
16900 9844 }
16901
1/2
✓ Branch 0 taken 2461 times.
✗ Branch 1 not taken.
2461 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
16902 return qe_invalid;
16903 2461 }
16904
2/2
✓ Branch 0 taken 94834 times.
✓ Branch 1 taken 8624 times.
103458 if(scr_has_flags & SCRHAS_SWARP)
16905 {
16906
2/2
✓ Branch 0 taken 34496 times.
✓ Branch 1 taken 8624 times.
43120 for(int32_t i=0; i<4; i++)
16907 {
16908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34496 times.
34496 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
16909 return qe_invalid;
16910 34496 }
16911
2/2
✓ Branch 0 taken 34496 times.
✓ Branch 1 taken 8624 times.
43120 for(int32_t i=0; i<4; i++)
16912 {
16913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34496 times.
34496 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16914 return qe_invalid;
16915 34496 }
16916
2/2
✓ Branch 0 taken 34496 times.
✓ Branch 1 taken 8624 times.
43120 for(int32_t i=0; i<4; i++)
16917 {
16918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34496 times.
34496 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
16919 return qe_invalid;
16920 34496 }
16921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8624 times.
8624 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
16922 return qe_invalid;
16923
1/2
✓ Branch 0 taken 8624 times.
✗ Branch 1 not taken.
8624 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16924 return qe_invalid;
16925 8624 }
16926
2/2
✓ Branch 0 taken 97121 times.
✓ Branch 1 taken 6337 times.
103458 if(scr_has_flags & SCRHAS_WARPRET)
16927 {
16928
2/2
✓ Branch 0 taken 25348 times.
✓ Branch 1 taken 6337 times.
31685 for(int32_t i=0; i<4; i++)
16929 {
16930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25348 times.
25348 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
16931 return qe_invalid;
16932 25348 }
16933
2/2
✓ Branch 0 taken 25348 times.
✓ Branch 1 taken 6337 times.
31685 for(int32_t i=0; i<4; i++)
16934 {
16935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25348 times.
25348 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
16936 return qe_invalid;
16937 25348 }
16938
1/2
✓ Branch 0 taken 6337 times.
✗ Branch 1 not taken.
6337 if(!p_getc(&(temp_mapscr->warparrivalx),f))
16939 return qe_invalid;
16940
1/2
✓ Branch 0 taken 6337 times.
✗ Branch 1 not taken.
6337 if(!p_getc(&(temp_mapscr->warparrivaly),f))
16941 return qe_invalid;
16942 6337 }
16943
2/2
✓ Branch 0 taken 90055 times.
✓ Branch 1 taken 13403 times.
103458 if(scr_has_flags & SCRHAS_LAYERS)
16944 {
16945
2/2
✓ Branch 0 taken 80418 times.
✓ Branch 1 taken 13403 times.
93821 for(int32_t k=0; k<6; k++)
16946 {
16947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80418 times.
80418 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16948 return qe_invalid;
16949 80418 }
16950
2/2
✓ Branch 0 taken 80418 times.
✓ Branch 1 taken 13403 times.
93821 for(int32_t k=0; k<6; k++)
16951 {
16952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80418 times.
80418 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16953 return qe_invalid;
16954 80418 }
16955
2/2
✓ Branch 0 taken 80418 times.
✓ Branch 1 taken 13403 times.
93821 for(int32_t k=0; k<6; k++)
16956 {
16957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80418 times.
80418 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16958 return qe_invalid;
16959 80418 }
16960
1/2
✓ Branch 0 taken 13403 times.
✗ Branch 1 not taken.
13403 if(!p_getc(&(temp_mapscr->hidelayers),f))
16961 return qe_invalid;
16962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13403 times.
13403 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
16963 return qe_invalid;
16964 13403 }
16965
2/2
✓ Branch 0 taken 103357 times.
✓ Branch 1 taken 101 times.
103458 if(scr_has_flags & SCRHAS_MAZE)
16966 {
16967
2/2
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 101 times.
505 for(int32_t k=0; k<4; k++)
16968 {
16969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 404 times.
404 if(!p_getc(&(temp_mapscr->path[k]),f))
16970 return qe_invalid;
16971 404 }
16972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
101 if(!p_getc(&(temp_mapscr->exitdir),f))
16973 return qe_invalid;
16974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
101 if (version >= 32)
16975 {
16976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
101 if (!p_getc(&temp_mapscr->maze_transition_wipe, f))
16977 return qe_invalid;
16978 101 }
16979 101 }
16980
2/2
✓ Branch 0 taken 75267 times.
✓ Branch 1 taken 28191 times.
103458 if(scr_has_flags & SCRHAS_D_S_U)
16981 {
16982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75267 times.
75267 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
16983 return qe_invalid;
16984
2/2
✓ Branch 0 taken 301068 times.
✓ Branch 1 taken 75267 times.
376335 for(int32_t k=0; k<4; k++)
16985 {
16986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 301068 times.
301068 if(!p_getc(&(temp_mapscr->door[k]),f))
16987 return qe_invalid;
16988
3/4
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 300708 times.
✓ Branch 2 taken 360 times.
✗ Branch 3 not taken.
301068 if(version < 29 && temp_mapscr->door[k] == dNONE)
16989 temp_mapscr->door[k] = dWALL;
16990 301068 }
16991
16992
1/2
✓ Branch 0 taken 75267 times.
✗ Branch 1 not taken.
75267 if(!p_getc(&(temp_mapscr->stairx),f))
16993 return qe_invalid;
16994
16995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75267 times.
75267 if(!p_getc(&(temp_mapscr->stairy),f))
16996 return qe_invalid;
16997
1/2
✓ Branch 0 taken 75267 times.
✗ Branch 1 not taken.
75267 if(!p_igetw(&(temp_mapscr->undercombo),f))
16998 return qe_invalid;
16999
1/2
✓ Branch 0 taken 75267 times.
✗ Branch 1 not taken.
75267 if(!p_getc(&(temp_mapscr->undercset),f))
17000 return qe_invalid;
17001 75267 }
17002
2/2
✓ Branch 0 taken 10488 times.
✓ Branch 1 taken 17703 times.
28191 else if(version < 29)
17003 {
17004
2/2
✓ Branch 0 taken 41952 times.
✓ Branch 1 taken 10488 times.
52440 for(int k = 0; k < 4; ++k)
17005 41952 temp_mapscr->door[k] = dWALL;
17006 10488 }
17007
2/2
✓ Branch 0 taken 97061 times.
✓ Branch 1 taken 6397 times.
103458 if(scr_has_flags & SCRHAS_FLAGS)
17008 {
17009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6397 times.
6397 if(!p_getc(&(temp_mapscr->flags),f))
17010 return qe_invalid;
17011
1/2
✓ Branch 0 taken 6397 times.
✗ Branch 1 not taken.
6397 if(!p_getc(&(temp_mapscr->flags2),f))
17012 return qe_invalid;
17013
1/2
✓ Branch 0 taken 6397 times.
✗ Branch 1 not taken.
6397 if(!p_getc(&(temp_mapscr->flags3),f))
17014 return qe_invalid;
17015
1/2
✓ Branch 0 taken 6397 times.
✗ Branch 1 not taken.
6397 if(!p_getc(&(temp_mapscr->flags4),f))
17016 return qe_invalid;
17017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6397 times.
6397 if(!p_getc(&(temp_mapscr->flags5),f))
17018 return qe_invalid;
17019
1/2
✓ Branch 0 taken 6397 times.
✗ Branch 1 not taken.
6397 if(!p_getc(&(temp_mapscr->flags6),f))
17020 return qe_invalid;
17021
1/2
✓ Branch 0 taken 6397 times.
✗ Branch 1 not taken.
6397 if(!p_getc(&(temp_mapscr->flags7),f))
17022 return qe_invalid;
17023
1/2
✓ Branch 0 taken 6397 times.
✗ Branch 1 not taken.
6397 if(!p_getc(&(temp_mapscr->flags8),f))
17024 return qe_invalid;
17025
1/2
✓ Branch 0 taken 6397 times.
✗ Branch 1 not taken.
6397 if(!p_getc(&(temp_mapscr->flags9),f))
17026 return qe_invalid;
17027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6397 times.
6397 if(!p_getc(&(temp_mapscr->flags10),f))
17028 return qe_invalid;
17029
1/2
✓ Branch 0 taken 6397 times.
✗ Branch 1 not taken.
6397 if(!p_getc(&(temp_mapscr->flags11),f))
17030 return qe_invalid;
17031 6397 }
17032
2/2
✓ Branch 0 taken 98211 times.
✓ Branch 1 taken 5247 times.
103458 if(scr_has_flags & SCRHAS_ENEMY)
17033 {
17034
2/2
✓ Branch 0 taken 52470 times.
✓ Branch 1 taken 5247 times.
57717 for(int32_t k=0; k<10; k++)
17035 {
17036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52470 times.
52470 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
17037 return qe_invalid;
17038
1/2
✓ Branch 0 taken 52470 times.
✗ Branch 1 not taken.
52470 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17039 temp_mapscr->enemy[k] = 0;
17040 52470 }
17041
1/2
✓ Branch 0 taken 5247 times.
✗ Branch 1 not taken.
5247 if(!p_getc(&(temp_mapscr->pattern),f))
17042 return qe_invalid;
17043 5247 }
17044
2/2
✓ Branch 0 taken 103055 times.
✓ Branch 1 taken 403 times.
103458 if(scr_has_flags & SCRHAS_CARRY)
17045 {
17046
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_igetw(&(temp_mapscr->noreset),f))
17047 return qe_invalid;
17048
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_igetw(&(temp_mapscr->nocarry),f))
17049 return qe_invalid;
17050
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_getc(&(temp_mapscr->nextmap),f))
17051 return qe_invalid;
17052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 403 times.
403 if(!p_getc(&(temp_mapscr->nextscr),f))
17053 return qe_invalid;
17054 403 }
17055
2/2
✓ Branch 0 taken 102893 times.
✓ Branch 1 taken 565 times.
103458 if(scr_has_flags & SCRHAS_SCRIPT)
17056 {
17057
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&(temp_mapscr->script),f))
17058 return qe_invalid;
17059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 if(!p_getc(&(temp_mapscr->preloadscript),f))
17060 return qe_invalid;
17061
2/2
✓ Branch 0 taken 4520 times.
✓ Branch 1 taken 565 times.
5085 for ( int32_t q = 0; q < 8; q++ )
17062 {
17063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4520 times.
4520 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
17064 return qe_invalid;
17065 4520 }
17066 565 }
17067
2/2
✓ Branch 0 taken 72840 times.
✓ Branch 1 taken 30618 times.
103458 if(scr_has_flags & SCRHAS_SECRETS)
17068 {
17069
2/2
✓ Branch 0 taken 3919104 times.
✓ Branch 1 taken 30618 times.
3949722 for(int32_t k=0; k<128; k++)
17070 {
17071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3919104 times.
3919104 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
17072 return qe_invalid;
17073 3919104 }
17074
2/2
✓ Branch 0 taken 3919104 times.
✓ Branch 1 taken 30618 times.
3949722 for(int32_t k=0; k<128; k++)
17075 {
17076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3919104 times.
3919104 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
17077 return qe_invalid;
17078 3919104 }
17079
2/2
✓ Branch 0 taken 3919104 times.
✓ Branch 1 taken 30618 times.
3949722 for(int32_t k=0; k<128; k++)
17080 {
17081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3919104 times.
3919104 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
17082 return qe_invalid;
17083 3919104 }
17084 30618 }
17085
2/2
✓ Branch 0 taken 39904 times.
✓ Branch 1 taken 63554 times.
103458 if(scr_has_flags & SCRHAS_COMBOFLAG)
17086 {
17087
2/2
✓ Branch 0 taken 11185504 times.
✓ Branch 1 taken 63554 times.
11249058 for(int32_t k=0; k<176; ++k)
17088 {
17089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11185504 times.
11185504 if(!p_igetw(&(temp_mapscr->data[k]),f))
17090 return qe_invalid;
17091 11185504 }
17092
2/2
✓ Branch 0 taken 11185504 times.
✓ Branch 1 taken 63554 times.
11249058 for(int32_t k=0; k<176; ++k)
17093 {
17094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11185504 times.
11185504 if(!p_getc(&(temp_mapscr->sflag[k]),f))
17095 return qe_invalid;
17096 11185504 }
17097
2/2
✓ Branch 0 taken 11185504 times.
✓ Branch 1 taken 63554 times.
11249058 for(int32_t k=0; k<176; ++k)
17098 {
17099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11185504 times.
11185504 if(!p_getc(&(temp_mapscr->cset[k]),f))
17100 return qe_invalid;
17101 11185504 }
17102 63554 }
17103
1/2
✓ Branch 0 taken 103458 times.
✗ Branch 1 not taken.
103458 if(scr_has_flags & SCRHAS_MISC)
17104 {
17105
1/2
✓ Branch 0 taken 103458 times.
✗ Branch 1 not taken.
103458 if(!p_igetw(&(temp_mapscr->color),f))
17106 return qe_invalid;
17107
1/2
✓ Branch 0 taken 103458 times.
✗ Branch 1 not taken.
103458 if(!p_getc(&(temp_mapscr->csensitive),f))
17108 return qe_invalid;
17109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103458 times.
103458 if(!p_getc(&(temp_mapscr->oceansfx),f))
17110 return qe_invalid;
17111
1/2
✓ Branch 0 taken 103458 times.
✗ Branch 1 not taken.
103458 if(!p_getc(&(temp_mapscr->bosssfx),f))
17112 return qe_invalid;
17113
1/2
✓ Branch 0 taken 103458 times.
✗ Branch 1 not taken.
103458 if(!p_getc(&(temp_mapscr->secretsfx),f))
17114 return qe_invalid;
17115
1/2
✓ Branch 0 taken 103458 times.
✗ Branch 1 not taken.
103458 if(!p_getc(&(temp_mapscr->holdupsfx),f))
17116 return qe_invalid;
17117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103458 times.
103458 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
17118 return qe_invalid;
17119
1/2
✓ Branch 0 taken 103458 times.
✗ Branch 1 not taken.
103458 if(!p_igetw(&(temp_mapscr->screen_midi),f))
17120 return qe_invalid;
17121
1/2
✓ Branch 0 taken 103458 times.
✗ Branch 1 not taken.
103458 if(!p_getc(&(temp_mapscr->lens_layer),f))
17122 return qe_invalid;
17123
2/2
✓ Branch 0 taken 10578 times.
✓ Branch 1 taken 92880 times.
103458 if(version > 27)
17124 {
17125
1/2
✓ Branch 0 taken 92880 times.
✗ Branch 1 not taken.
92880 if(!p_getc(&(temp_mapscr->lens_show),f))
17126 return qe_invalid;
17127
1/2
✓ Branch 0 taken 92880 times.
✗ Branch 1 not taken.
92880 if(!p_getc(&(temp_mapscr->lens_hide),f))
17128 return qe_invalid;
17129 92880 }
17130 103458 }
17131 else
17132 {
17133 temp_mapscr->screen_midi = -1;
17134 temp_mapscr->csensitive = 1;
17135 }
17136 //FFC
17137 103458 bool old_ff = version < 25;
17138 103458 dword bits = 0;
17139 103458 word numffc = 32;
17140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103458 times.
103458 if(old_ff)
17141 {
17142 if(!p_igetl(&bits,f))
17143 return qe_invalid;
17144 }
17145 else
17146 {
17147
2/4
✓ Branch 0 taken 103458 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 103458 times.
103458 if(!p_igetw(&numffc,f) || numffc > MAXFFCS)
17148 return qe_invalid;
17149 }
17150
17151 103458 temp_mapscr->ffcCountMarkDirty();
17152 103458 temp_mapscr->ffcs.clear();
17153 103458 temp_mapscr->resizeFFC(numffc);
17154
17155 byte tempbyte;
17156 word tempw;
17157
4/6
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 103310 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 148 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 148 times.
103458 static ffcdata nil_ffc;
17158
2/2
✓ Branch 0 taken 1926537 times.
✓ Branch 1 taken 103458 times.
2029995 for(word m = 0; m < numffc; ++m)
17159 {
17160
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1926537 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1926537 if(old_ff && !(bits & (1<<m))) continue;
17161
17162
1/2
✓ Branch 0 taken 1926537 times.
✗ Branch 1 not taken.
1926537 ffcdata& tempffc = (m < MAXFFCS)
17163 1926537 ? temp_mapscr->ffcs[m]
17164 : nil_ffc; //sanity
17165
17166
1/2
✓ Branch 0 taken 1926537 times.
✗ Branch 1 not taken.
1926537 if(!p_igetw(&tempw,f))
17167 return qe_invalid;
17168
3/4
✓ Branch 0 taken 1926537 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13892 times.
✓ Branch 3 taken 1912645 times.
1926537 if(!old_ff && !tempw) //empty ffc, nothing more to load
17169 1912645 continue;
17170 13892 tempffc.data = tempw;
17171
17172
1/2
✓ Branch 0 taken 13892 times.
✗ Branch 1 not taken.
13892 if(!p_getc(&(tempffc.cset),f))
17173 return qe_invalid;
17174
1/2
✓ Branch 0 taken 13892 times.
✗ Branch 1 not taken.
13892 if(!p_igetw(&(tempffc.delay),f))
17175 return qe_invalid;
17176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13892 times.
13892 if(!p_igetzf(&(tempffc.x),f))
17177 return qe_invalid;
17178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13892 times.
13892 if(!p_igetzf(&(tempffc.y),f))
17179 return qe_invalid;
17180
1/2
✓ Branch 0 taken 13892 times.
✗ Branch 1 not taken.
13892 if(!p_igetzf(&(tempffc.vx),f))
17181 return qe_invalid;
17182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13892 times.
13892 if(!p_igetzf(&(tempffc.vy),f))
17183 return qe_invalid;
17184
1/2
✓ Branch 0 taken 13892 times.
✗ Branch 1 not taken.
13892 if(!p_igetzf(&(tempffc.ax),f))
17185 return qe_invalid;
17186
1/2
✓ Branch 0 taken 13892 times.
✗ Branch 1 not taken.
13892 if(!p_igetzf(&(tempffc.ay),f))
17187 return qe_invalid;
17188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13892 times.
13892 if(!p_getc(&(tempffc.link),f))
17189 return qe_invalid;
17190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13892 times.
13892 if(version < 24)
17191 {
17192 if(!p_getc(&tempbyte,f))
17193 return qe_invalid;
17194 tempffc.hit_width = (tempbyte&0x3F)+1;
17195 tempffc.txsz = (tempbyte>>6)+1;
17196 if(!p_getc(&tempbyte,f))
17197 return qe_invalid;
17198 tempffc.hit_height = (tempbyte&0x3F)+1;
17199 tempffc.tysz = (tempbyte>>6)+1;
17200 }
17201 else
17202 {
17203
1/2
✓ Branch 0 taken 13892 times.
✗ Branch 1 not taken.
13892 if(!p_igetl(&(tempffc.hit_width),f))
17204 return qe_invalid;
17205
1/2
✓ Branch 0 taken 13892 times.
✗ Branch 1 not taken.
13892 if(!p_igetl(&(tempffc.hit_height),f))
17206 return qe_invalid;
17207
1/2
✓ Branch 0 taken 13892 times.
✗ Branch 1 not taken.
13892 if(!p_getc(&(tempffc.txsz),f))
17208 return qe_invalid;
17209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13892 times.
13892 if(!p_getc(&(tempffc.tysz),f))
17210 return qe_invalid;
17211 }
17212
1/2
✓ Branch 0 taken 13892 times.
✗ Branch 1 not taken.
13892 if(!p_igetl(&(tempffc.flags),f))
17213 return qe_invalid;
17214 13892 tempffc.updateSolid();
17215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13892 times.
13892 if(!p_igetw(&(tempffc.script),f))
17216 return qe_invalid;
17217
2/2
✓ Branch 0 taken 111136 times.
✓ Branch 1 taken 13892 times.
125028 for(auto q = 0; q < 8; ++q)
17218 {
17219
1/2
✓ Branch 0 taken 111136 times.
✗ Branch 1 not taken.
111136 if(!p_igetl(&(tempffc.initd[q]),f))
17220 return qe_invalid;
17221 111136 }
17222
2/2
✓ Branch 0 taken 7990 times.
✓ Branch 1 taken 5902 times.
13892 if(version < 33)
17223 {
17224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7990 times.
7990 if(!p_getc(&(tempbyte),f))
17225 return qe_invalid;
17226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7990 times.
7990 if(!p_getc(&(tempbyte),f))
17227 return qe_invalid;
17228 7990 }
17229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5902 times.
5902 else if(!p_getc(&(tempffc.layer),f))
17230 return qe_invalid;
17231
17232
1/2
✓ Branch 0 taken 13892 times.
✗ Branch 1 not taken.
13892 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17233 {
17234 tempffc.script = 0;
17235 for(int q = 0; q < 8; ++q)
17236 tempffc.initd[q] = 0;
17237 }
17238 13892 }
17239 //END FFC
17240
2/2
✓ Branch 0 taken 38497 times.
✓ Branch 1 taken 64961 times.
103458 if(version > 29)
17241
1/2
✓ Branch 0 taken 64961 times.
✗ Branch 1 not taken.
64961 if(!p_getlstr(&temp_mapscr->usr_notes, f))
17242 return qe_invalid;
17243 }
17244
17245 1289930 temp_mapscr->shinkToFitFFCs();
17246
17247 1289930 return 0;
17248 1382312 }
17249
17250 467 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17251 {
17252
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 24 times.
467 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
17253 467 int32_t screen=0;
17254
17255 467 word version=0;
17256 dword dummy;
17257 int32_t screens_to_read;
17258
17259 467 mapscr temp_mapscr{};
17260 word temp_map_count;
17261 dword section_size;
17262
17263
5/6
✓ Branch 0 taken 449 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 443 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
467 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17264 {
17265 18 screens_to_read=MAPSCRS192b136;
17266 18 }
17267 else
17268 {
17269 449 screens_to_read=MAPSCRS;
17270 }
17271
17272
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 24 times.
467 if(Header->zelda_version > 0x192)
17273 {
17274 //section version info
17275
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetw(&version,f))
17276 {
17277 return qe_invalid;
17278 }
17279
17280 443 FFCore.quest_format[vMaps] = version;
17281
17282
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetw(&dummy,f))
17283 {
17284 return qe_invalid;
17285 }
17286
17287 //section size
17288
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetl(&section_size,f))
17289 {
17290 return qe_invalid;
17291 }
17292
17293 //finally... section data
17294
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetw(&temp_map_count,f))
17295 {
17296 return 5;
17297 }
17298 443 }
17299 else
17300 {
17301 24 temp_map_count=map_count;
17302 }
17303
17304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if (temp_map_count > MAXMAPS)
17305 {
17306 return qe_invalid;
17307 }
17308
17309
2/2
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 1 times.
467 if (!should_skip)
17310 {
17311 466 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17312 466 TheMaps.clear();
17313
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 TheMaps.resize(_mapsSize);
17314 466 old_combo_pages.clear();
17315
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 old_combo_pages.resize(_mapsSize);
17316 466 map_autolayers.clear();
17317
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 map_autolayers.resize(temp_map_count*6);
17318
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 134 times.
466 if(version >= 31)
17319 134 Regions = {};
17320 466 }
17321
17322
4/4
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 10299 times.
✓ Branch 2 taken 10299 times.
✓ Branch 3 taken 467 times.
10766 for(int32_t i=0; i<temp_map_count && i<MAXMAPS; i++)
17323 {
17324 10299 byte valid=1;
17325
2/2
✓ Branch 0 taken 1570 times.
✓ Branch 1 taken 8729 times.
10299 if(version > 22)
17326 {
17327
2/4
✓ Branch 0 taken 1570 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1570 times.
✗ Branch 3 not taken.
1570 if(!p_getc(&valid,f))
17328 return qe_invalid;
17329 1570 }
17330
2/2
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 10169 times.
10299 if(valid)
17331 {
17332
2/2
✓ Branch 0 taken 8859 times.
✓ Branch 1 taken 1310 times.
10169 if (version > 25)
17333 {
17334
2/2
✓ Branch 0 taken 7860 times.
✓ Branch 1 taken 1310 times.
9170 for(int q = 0; q < 6; ++q)
17335 {
17336
2/4
✓ Branch 0 taken 7860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7860 times.
✗ Branch 3 not taken.
7860 if(!p_igetw(&map_autolayers[i*6+q],f))
17337 return qe_invalid;
17338 7860 }
17339 1310 }
17340
17341
2/2
✓ Branch 0 taken 9301 times.
✓ Branch 1 taken 868 times.
10169 if (version >= 31)
17342 {
17343 static regions_data tmp_rd;
17344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 868 times.
868 regions_data& rd = should_skip ? tmp_rd : Regions[i];
17345
2/2
✓ Branch 0 taken 6944 times.
✓ Branch 1 taken 868 times.
7812 for(int32_t j=0; j<8; j++)
17346 {
17347
2/2
✓ Branch 0 taken 55552 times.
✓ Branch 1 taken 6944 times.
62496 for(int32_t k=0; k<8; k++)
17348 {
17349
2/4
✓ Branch 0 taken 55552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55552 times.
✗ Branch 3 not taken.
55552 if(!p_getc(&rd.region_ids[j][k],f))
17350 {
17351 return qe_invalid;
17352 }
17353 55552 }
17354 6944 }
17355 868 }
17356 10169 }
17357
2/2
✓ Branch 0 taken 1399992 times.
✓ Branch 1 taken 10299 times.
1410291 for(int32_t j=0; j<screens_to_read; j++)
17358 {
17359 1399992 screen=i*MAPSCRS+j;
17360
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 1399720 times.
1399992 mapscr* scr = should_skip ? &temp_mapscr : &TheMaps[screen];
17361 1399992 scr->map = i;
17362 1399992 scr->screen = j;
17363
2/2
✓ Branch 0 taken 1382312 times.
✓ Branch 1 taken 17680 times.
1399992 if(valid)
17364
1/2
✓ Branch 0 taken 1382312 times.
✗ Branch 1 not taken.
1382312 readmapscreen(f, Header, scr, version, screen);
17365
1/2
✓ Branch 0 taken 17680 times.
✗ Branch 1 not taken.
17680 else if (!should_skip)
17366
1/2
✓ Branch 0 taken 17680 times.
✗ Branch 1 not taken.
17680 clear_screen(scr);
17367 1399992 }
17368
17369
2/2
✓ Branch 0 taken 10297 times.
✓ Branch 1 taken 2 times.
10299 if (should_skip)
17370 2 continue;
17371
17372
5/6
✓ Branch 0 taken 10129 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 10111 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
10297 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17373 {
17374 168 int32_t index = (i*MAPSCRS+132);
17375
17376
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 TheMaps[index]=TheMaps[index-1];
17377
17378 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17379 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17380 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17381
17382
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 168 times.
672 for(int32_t j=133; j<MAPSCRS; j++)
17383 {
17384 504 screen=i*MAPSCRS+j;
17385
17386
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 TheMaps[screen].zero_memory();
17387 504 TheMaps[screen].valid = mVERSION;
17388 504 TheMaps[screen].screen_midi = -1;
17389 504 TheMaps[screen].csensitive = 1;
17390 504 }
17391 168 }
17392
17393
5/6
✓ Branch 0 taken 10129 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 10111 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
10297 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17394 {
17395
2/2
✓ Branch 0 taken 22848 times.
✓ Branch 1 taken 168 times.
23016 for(int32_t j=0; j<MAPSCRS; j++)
17396 {
17397 22848 screen=i*MAPSCRS+j;
17398
1/2
✓ Branch 0 taken 22848 times.
✗ Branch 1 not taken.
22848 TheMaps[screen].door_combo_set=MakeDoors(i, j);
17399
17400
2/2
✓ Branch 0 taken 2924544 times.
✓ Branch 1 taken 22848 times.
2947392 for(int32_t k=0; k<128; k++)
17401 {
17402
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretcset[k]=tcmbcset2(i, TheMaps[screen].secretcombo[k]);
17403
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretflag[k]=tcmbflag2(i, TheMaps[screen].secretcombo[k]);
17404
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretcombo[k]=tcmbdat2(i, j, TheMaps[screen].secretcombo[k]);
17405 2924544 }
17406 22848 }
17407 168 }
17408 10297 }
17409 467 map_count = temp_map_count;
17410 467 return 0;
17411 467 }
17412
17413
17414 9001982 void update_combo(newcombo& cmb, word section_version)
17415 {
17416
2/2
✓ Branch 0 taken 1200436 times.
✓ Branch 1 taken 7801546 times.
9001982 if(section_version < 40)
17417 {
17418
3/3
✓ Branch 0 taken 5168 times.
✓ Branch 1 taken 46100 times.
✓ Branch 2 taken 7750278 times.
7801546 switch(cmb.type)
17419 {
17420 case cWATER: case cSHALLOWWATER:
17421 46100 cmb.attribytes[6] = iwRipples;
17422 46100 break;
17423 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17424 5168 cmb.attribytes[6] = iwTallGrass;
17425 5168 break;
17426 }
17427 7801546 }
17428
2/2
✓ Branch 0 taken 853005 times.
✓ Branch 1 taken 8148977 times.
9001982 if(section_version < 49)
17429 {
17430
4/4
✓ Branch 0 taken 8113766 times.
✓ Branch 1 taken 35211 times.
✓ Branch 2 taken 15697 times.
✓ Branch 3 taken 8098069 times.
8148977 if(cmb.type == cWATER || cmb.type == cSHALLOWWATER)
17431 50908 cmb.sfx_landing = WAV_ZN1SPLASH;
17432 8148977 }
17433 9001982 }
17434 293 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17435 {
17436
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 24 times.
293 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
17437
17438
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 292 times.
293 if (!should_skip)
17439 {
17440 292 reset_all_combo_animations();
17441 292 init_combo_classes();
17442 292 }
17443
17444 // combos
17445 293 word combos_used=0;
17446 int32_t dummy;
17447 byte padding;
17448 293 newcombo temp_combo;
17449
17450
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 292 times.
293 if (!should_skip)
17451
2/2
✓ Branch 0 taken 19061760 times.
✓ Branch 1 taken 292 times.
19062052 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17452
1/2
✓ Branch 0 taken 19061760 times.
✗ Branch 1 not taken.
19062052 combobuf[q].clear();
17453
17454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 293 times.
293 if(version < 0x174)
17455 {
17456 combos_used=1024;
17457 }
17458
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 18 times.
293 else if(version < 0x191)
17459 {
17460 18 combos_used=2048;
17461 18 }
17462 else
17463 {
17464
2/4
✓ Branch 0 taken 275 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275 times.
✗ Branch 3 not taken.
275 if(!p_igetw(&combos_used,f))
17465 {
17466 return qe_invalid;
17467 }
17468 }
17469
17470 //finally... section data
17471
2/2
✓ Branch 0 taken 7666530 times.
✓ Branch 1 taken 293 times.
7666823 for(int32_t i=0; i<combos_used; i++)
17472 {
17473
1/2
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
7666530 temp_combo.clear();
17474
17475
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463562 times.
7666530 if ( section_version >= 11 )
17476 {
17477
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.tile,f))
17478 {
17479 return qe_invalid;
17480 }
17481 202968 }
17482 else
17483 {
17484
2/4
✓ Branch 0 taken 7463562 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7463562 times.
✗ Branch 3 not taken.
7463562 if(!p_igetw(&temp_combo.tile,f))
17485 {
17486 return qe_invalid;
17487 }
17488 }
17489 7666530 temp_combo.o_tile = temp_combo.tile;
17490
2/4
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7666530 times.
✗ Branch 3 not taken.
7666530 if(!p_getc(&temp_combo.flip,f))
17491 {
17492 return qe_invalid;
17493 }
17494
17495
2/4
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7666530 times.
✗ Branch 3 not taken.
7666530 if(!p_getc(&temp_combo.walk,f))
17496 {
17497 return qe_invalid;
17498 }
17499
17500
2/4
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7666530 times.
✗ Branch 3 not taken.
7666530 if(!p_getc(&temp_combo.type,f))
17501 {
17502 return qe_invalid;
17503 }
17504
17505
2/4
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7666530 times.
✗ Branch 3 not taken.
7666530 if(!p_getc(&temp_combo.csets,f))
17506 {
17507 return qe_invalid;
17508 }
17509
17510
2/2
✓ Branch 0 taken 69774 times.
✓ Branch 1 taken 7596756 times.
7666530 if(version < 0x193)
17511 {
17512
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17513 return qe_invalid;
17514
17515
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17516 return qe_invalid;
17517
17518
2/2
✓ Branch 0 taken 32910 times.
✓ Branch 1 taken 36864 times.
69774 if(version < 0x192)
17519 {
17520
1/2
✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
36864 if(version == 0x191)
17521 {
17522 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17523 {
17524 if(!p_getc(&padding,f))
17525 return qe_invalid;
17526 }
17527 }
17528 36864 }
17529 69774 }
17530
2/2
✓ Branch 0 taken 7629666 times.
✓ Branch 1 taken 36864 times.
7666530 if(version >= 0x192)
17531 {
17532
2/4
✓ Branch 0 taken 7629666 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7629666 times.
✗ Branch 3 not taken.
7629666 if(!p_getc(&temp_combo.frames,f))
17533 return qe_invalid;
17534
17535
2/4
✓ Branch 0 taken 7629666 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7629666 times.
✗ Branch 3 not taken.
7629666 if(!p_getc(&temp_combo.speed,f))
17536 return qe_invalid;
17537
17538
2/4
✓ Branch 0 taken 7629666 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7629666 times.
✗ Branch 3 not taken.
7629666 if(!p_igetw(&temp_combo.nextcombo,f))
17539 return qe_invalid;
17540
17541
2/4
✓ Branch 0 taken 7629666 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7629666 times.
✗ Branch 3 not taken.
7629666 if(!p_getc(&temp_combo.nextcset,f))
17542 return qe_invalid;
17543
17544 //Base flag
17545
2/2
✓ Branch 0 taken 4741258 times.
✓ Branch 1 taken 2888408 times.
7629666 if(section_version>=3)
17546
2/4
✓ Branch 0 taken 4741258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741258 times.
✗ Branch 3 not taken.
4741258 if(!p_getc(&temp_combo.flag,f))
17547 return qe_invalid;
17548
17549
2/2
✓ Branch 0 taken 4741258 times.
✓ Branch 1 taken 2888408 times.
7629666 if(section_version>=4)
17550 {
17551
2/4
✓ Branch 0 taken 4741258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741258 times.
✗ Branch 3 not taken.
4741258 if(!p_getc(&temp_combo.skipanim,f))
17552 return qe_invalid;
17553
17554
2/4
✓ Branch 0 taken 4741258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741258 times.
✗ Branch 3 not taken.
4741258 if(!p_igetw(&temp_combo.nexttimer,f))
17555 return qe_invalid;
17556 4741258 }
17557
17558
2/2
✓ Branch 0 taken 4741258 times.
✓ Branch 1 taken 2888408 times.
7629666 if(section_version>=5)
17559
2/4
✓ Branch 0 taken 4741258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741258 times.
✗ Branch 3 not taken.
4741258 if(!p_getc(&temp_combo.skipanimy,f))
17560 return qe_invalid;
17561
17562
2/2
✓ Branch 0 taken 4741258 times.
✓ Branch 1 taken 2888408 times.
7629666 if(section_version>=6)
17563 {
17564
2/4
✓ Branch 0 taken 4741258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741258 times.
✗ Branch 3 not taken.
4741258 if(!p_getc(&temp_combo.animflags,f))
17565 return qe_invalid;
17566
17567
1/2
✓ Branch 0 taken 4741258 times.
✗ Branch 1 not taken.
4741258 if(section_version == 6)
17568 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17569 4741258 }
17570
17571
2/2
✓ Branch 0 taken 7426698 times.
✓ Branch 1 taken 202968 times.
7629666 if(section_version>=8) //combo Attributes[4] and userflags.
17572 {
17573
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 811872 times.
1014840 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17574
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_igetl(&temp_combo.attributes[q],f))
17575 return qe_invalid;
17576
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.usrflags,f))
17577 return qe_invalid;
17578
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 if(section_version >= 20)
17579
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.genflags,f))
17580 return qe_invalid;
17581 202968 }
17582
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426698 times.
7629666 if(section_version>=10) //combo trigger flags
17583 {
17584
2/2
✓ Branch 0 taken 608904 times.
✓ Branch 1 taken 202968 times.
811872 for ( int32_t q = 0; q < 3; q++ )
17585
2/4
✓ Branch 0 taken 608904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 608904 times.
✗ Branch 3 not taken.
608904 if(!p_igetl(&temp_combo.triggerflags[q],f))
17586 return qe_invalid;
17587 202968 }
17588
1/2
✓ Branch 0 taken 7426698 times.
✗ Branch 1 not taken.
7426698 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17589 {
17590 for ( int32_t q = 0; q < 2; q++ )
17591 if(!p_igetl(&temp_combo.triggerflags[q],f))
17592 return qe_invalid;
17593 }
17594
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426698 times.
7629666 if(section_version >= 9)
17595
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.triggerlevel,f))
17596 return qe_invalid;
17597
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426698 times.
7629666 if(section_version >= 22)
17598
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.triggerbtn,f))
17599 return qe_invalid;
17600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 24)
17601 {
17602 if(!p_getc(&temp_combo.triggeritem,f))
17603 return qe_invalid;
17604 if(!p_getc(&temp_combo.trigtimer,f))
17605 return qe_invalid;
17606 }
17607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 25)
17608 if(!p_getc(&temp_combo.trigsfx,f))
17609 return qe_invalid;
17610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 27)
17611 if(!p_igetl(&temp_combo.trigchange,f))
17612 return qe_invalid;
17613
17614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 29)
17615 {
17616 if(!p_igetw(&temp_combo.trigprox,f))
17617 return qe_invalid;
17618 if(!p_getc(&temp_combo.trigctr,f))
17619 return qe_invalid;
17620 if(!p_igetl(&temp_combo.trigctramnt,f))
17621 return qe_invalid;
17622 }
17623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 30)
17624 if(!p_getc(&temp_combo.triglbeam,f))
17625 return qe_invalid;
17626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 31)
17627 {
17628 if(!p_getc(&temp_combo.trigcschange,f))
17629 return qe_invalid;
17630 if(!p_igetw(&temp_combo.spawnitem,f))
17631 return qe_invalid;
17632 if(!p_igetw(&temp_combo.spawnenemy,f))
17633 return qe_invalid;
17634 if(!p_getc(&temp_combo.exstate,f))
17635 return qe_invalid;
17636 if(!p_igetl(&temp_combo.spawnip,f))
17637 return qe_invalid;
17638 if(!p_getc(&temp_combo.trigcopycat,f))
17639 return qe_invalid;
17640 }
17641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 32)
17642 if(!p_getc(&temp_combo.trigcooldown,f))
17643 return qe_invalid;
17644
17645
2/2
✓ Branch 0 taken 7426698 times.
✓ Branch 1 taken 202968 times.
7629666 if(section_version>=12) //combo label
17646 {
17647 char label[12];
17648 202968 label[11] = '\0';
17649
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 2232648 times.
2435616 for ( int32_t q = 0; q < 11; q++ )
17650
2/4
✓ Branch 0 taken 2232648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2232648 times.
✗ Branch 3 not taken.
2232648 if(!p_getc(&label[q],f))
17651 return qe_invalid;
17652
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 temp_combo.label = label;
17653 202968 }
17654
2/2
✓ Branch 0 taken 7426698 times.
✓ Branch 1 taken 202968 times.
7629666 if(section_version>=13) //attribytes[4]
17655
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 0; q < 4; q++ )
17656
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17657 202968 return qe_invalid;
17658 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17659 * This fixes a poor implementation of a ->next flag bug thing.
17660 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17661 * there was a version bump a few weeks before a change that broke stuff.
17662 */
17663
3/4
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426698 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 202968 times.
7629666 if (section_version >= 13 && section_version < 21)
17664 {
17665 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17666 }
17667 //combo scripts
17668
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426698 times.
7629666 if(section_version>=14)
17669 {
17670
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.script,f))
17671 return qe_invalid;
17672
2/2
✓ Branch 0 taken 405936 times.
✓ Branch 1 taken 202968 times.
608904 for ( int32_t q = 0; q < 2; q++ )
17673
2/4
✓ Branch 0 taken 405936 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405936 times.
✗ Branch 3 not taken.
405936 if(!p_igetl(&temp_combo.initd[q],f))
17674 return qe_invalid;
17675 202968 }
17676
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426698 times.
7629666 if(section_version>=15)
17677 {
17678
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17679
2/2
✓ Branch 0 taken 107633 times.
✓ Branch 1 taken 95335 times.
202968 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17680
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
17681
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
17682 202968 }
17683
2/2
✓ Branch 0 taken 7426698 times.
✓ Branch 1 taken 202968 times.
7629666 if(section_version>=17) //attribytes[4]
17684 {
17685
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17686
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17687 return qe_invalid;
17688
2/2
✓ Branch 0 taken 1623744 times.
✓ Branch 1 taken 202968 times.
1826712 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17689
2/4
✓ Branch 0 taken 1623744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1623744 times.
✗ Branch 3 not taken.
1623744 if(!p_igetw(&temp_combo.attrishorts[q],f))
17690 return qe_invalid;
17691 202968 }
17692
17693
2/2
✓ Branch 0 taken 7596756 times.
✓ Branch 1 taken 32910 times.
7629666 if(version < 0x193)
17694
2/2
✓ Branch 0 taken 362010 times.
✓ Branch 1 taken 32910 times.
394920 for(int32_t q=0; q<11; q++)
17695
2/4
✓ Branch 0 taken 362010 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 362010 times.
✗ Branch 3 not taken.
362010 if(!p_getc(&dummy,f))
17696 32910 return qe_invalid;
17697 7629666 }
17698
17699 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17700
3/6
✓ Branch 0 taken 4741258 times.
✓ Branch 1 taken 2925272 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4741258 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7666530 if((version < 0x211)||((version == 0x211)&&(build<7)))
17701 {
17702
2/2
✓ Branch 0 taken 2885336 times.
✓ Branch 1 taken 39936 times.
2925272 if(!get_qr(qr_NEWENEMYTILES))
17703 {
17704
1/5
✓ Branch 0 taken 39936 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
39936 switch(temp_combo.tile)
17705 {
17706 case 130:
17707 temp_combo.tile = 132;
17708 break;
17709
17710 case 131:
17711 temp_combo.tile = 133;
17712 break;
17713
17714 case 132:
17715 temp_combo.tile = 130;
17716 break;
17717
17718 case 133:
17719 temp_combo.tile = 131;
17720 break;
17721 }
17722 39936 }
17723 2925272 }
17724
17725
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463562 times.
7666530 if(section_version < 15)
17726 7463562 temp_combo.o_tile = temp_combo.tile;
17727
17728
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463562 times.
7666530 if(section_version<18) //upper bits for .walk
17729 7463562 temp_combo.walk |= 0xF0;
17730
17731
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463562 times.
7666530 if(section_version < 19)
17732
2/2
✓ Branch 0 taken 29854248 times.
✓ Branch 1 taken 7463562 times.
37317810 for(int32_t q = 0; q < 4; ++q)
17733 37317810 temp_combo.attributes[q] *= 10000L;
17734
17735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 if(section_version < 23)
17736 {
17737
2/2
✓ Branch 0 taken 15359 times.
✓ Branch 1 taken 7651171 times.
7666530 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17738 {
17739 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17740 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17741 case cTRIGGERGENERIC: case cCSWITCH:
17742 15359 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17743 15359 }
17744 7666530 }
17745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 if(section_version < 25)
17746 {
17747
2/2
✓ Branch 0 taken 27600 times.
✓ Branch 1 taken 7638930 times.
7666530 switch(temp_combo.type)
17748 {
17749 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27600 times.
27600 if(!(temp_combo.usrflags & cflag3))
17751 27600 temp_combo.attribytes[3] = WAV_DOOR;
17752 27600 temp_combo.usrflags &= ~cflag3;
17753 27600 break;
17754 }
17755 7666530 }
17756
17757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 if(section_version < 26)
17758
2/2
✓ Branch 0 taken 7665388 times.
✓ Branch 1 taken 1142 times.
7667672 if(temp_combo.type == cARMOS)
17759
1/2
✓ Branch 0 taken 1142 times.
✗ Branch 1 not taken.
1142 if(temp_combo.usrflags & cflag1)
17760 temp_combo.usrflags |= cflag3;
17761
17762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 if(section_version < 27)
17763 {
17764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17765 temp_combo.trigchange = 1;
17766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17767 temp_combo.trigchange = -1;
17768 7666530 else temp_combo.trigchange = 0;
17769 7666530 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17770 7666530 }
17771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 if(section_version < 28)
17772 {
17773
2/2
✓ Branch 0 taken 15669 times.
✓ Branch 1 taken 7650861 times.
7666530 switch(temp_combo.type)
17774 {
17775 case cLOCKBLOCK: case cLOCKEDCHEST:
17776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15669 times.
15669 if(temp_combo.usrflags & cflag7)
17777 temp_combo.usrflags |= cflag8;
17778 15669 else temp_combo.usrflags &= ~cflag8;
17779 15669 temp_combo.usrflags &= ~cflag7;
17780 15669 break;
17781 }
17782
2/2
✓ Branch 0 taken 782 times.
✓ Branch 1 taken 7665748 times.
7666530 switch(temp_combo.type)
17783 {
17784 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
17785 782 temp_combo.attrishorts[2] = -1;
17786 782 temp_combo.usrflags |= cflag7;
17787 782 break;
17788 }
17789 7666530 }
17790
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463562 times.
7666530 if(section_version < 20)
17791 {
17792 7463562 temp_combo.genflags = 0;
17793
2/2
✓ Branch 0 taken 144654 times.
✓ Branch 1 taken 7318908 times.
7463562 switch(temp_combo.type)
17794 {
17795 case cPUSH_WAIT: case cPUSH_HEAVY:
17796 case cPUSH_HW: case cL_STATUE:
17797 case cR_STATUE: case cPUSH_HEAVY2:
17798 case cPUSH_HW2: case cPOUND:
17799 case cC_STATUE: case cMIRROR:
17800 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17801 case cMAGICPRISM: case cMAGICPRISM4:
17802 case cMAGICSPONGE: case cEYEBALL_A:
17803 case cEYEBALL_B: case cEYEBALL_4:
17804 case cBUSH: case cFLOWERS:
17805 case cLOCKBLOCK: case cLOCKBLOCK2:
17806 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17807 case cCHEST: case cCHEST2:
17808 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17809 case cBOSSCHEST: case cBOSSCHEST2:
17810 case cBUSHNEXT: case cBUSHTOUCHY:
17811 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17812 case cSIGNPOST: case cCSWITCHBLOCK:
17813 case cTORCH: case cTRIGGERGENERIC:
17814
1/2
✓ Branch 0 taken 144654 times.
✗ Branch 1 not taken.
144654 if(temp_combo.usrflags & cflag16)
17815 {
17816 temp_combo.genflags |= cflag1;
17817 temp_combo.usrflags &= ~cflag16;
17818 }
17819 144654 break;
17820 }
17821 7463562 }
17822
17823 7666530 update_combo(temp_combo, section_version);
17824
17825
3/4
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7651611 times.
✓ Branch 3 taken 14919 times.
7666530 if(i>=start_combo && !should_skip)
17826 {
17827
1/2
✓ Branch 0 taken 7651611 times.
✗ Branch 1 not taken.
7651611 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17828 {
17829 temp_combo.script = 0;
17830 for(int q = 0; q < 8; ++q)
17831 temp_combo.initd[q] = 0;
17832 }
17833
1/2
✓ Branch 0 taken 7651611 times.
✗ Branch 1 not taken.
7651611 combobuf[i] = temp_combo;
17834 7651611 }
17835 7666530 }
17836
17837
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 1 times.
293 if (should_skip)
17838 1 return 0;
17839
17840
5/6
✓ Branch 0 taken 274 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 269 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
292 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
17841 {
17842
2/2
✓ Branch 0 taken 1501440 times.
✓ Branch 1 taken 23 times.
1501463 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17843 {
17844
2/2
✓ Branch 0 taken 1501225 times.
✓ Branch 1 taken 215 times.
1501440 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
17845 {
17846 215 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
17847 215 }
17848 1501440 }
17849 23 }
17850
17851 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
17852
4/6
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 233 times.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
292 if(version == 0x210 && get_app_id() != App::zquest)
17853 {
17854
2/2
✓ Branch 0 taken 3851520 times.
✓ Branch 1 taken 59 times.
3851579 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17855
2/2
✓ Branch 0 taken 3851335 times.
✓ Branch 1 taken 185 times.
3851705 if(combobuf[tmpcounter].type == cLADDERONLY)
17856 185 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
17857 59 }
17858
17859
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 82 times.
292 if(section_version<7)
17860 {
17861
2/2
✓ Branch 0 taken 5352960 times.
✓ Branch 1 taken 82 times.
5353042 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17862 {
17863
6/9
✓ Branch 0 taken 5350008 times.
✓ Branch 1 taken 853 times.
✓ Branch 2 taken 791 times.
✓ Branch 3 taken 603 times.
✓ Branch 4 taken 174 times.
✓ Branch 5 taken 531 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
5352960 switch(combobuf[tmpcounter].type)
17864 {
17865 case cSLASH:
17866 853 combobuf[tmpcounter].type=cSLASHTOUCHY;
17867 853 break;
17868
17869 case cSLASHITEM:
17870 791 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
17871 791 break;
17872
17873 case cBUSH:
17874 603 combobuf[tmpcounter].type=cBUSHTOUCHY;
17875 603 break;
17876
17877 case cFLOWERS:
17878 174 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
17879 174 break;
17880
17881 case cTALLGRASS:
17882 531 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
17883 531 break;
17884
17885 case cSLASHNEXT:
17886 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
17887 break;
17888
17889 case cSLASHNEXTITEM:
17890 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
17891 break;
17892
17893 case cBUSHNEXT:
17894 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
17895 break;
17896 }
17897 5352960 }
17898 82 }
17899
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 287 times.
292 if (section_version < 16)
17900 {
17901
2/2
✓ Branch 0 taken 18735360 times.
✓ Branch 1 taken 287 times.
18735647 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17902 {
17903
2/2
✓ Branch 0 taken 18706079 times.
✓ Branch 1 taken 29281 times.
18735360 if (combobuf[tmpcounter].type == cWATER)
17904 {
17905 29281 combobuf[tmpcounter].attributes[0] = 40000L;
17906 29281 }
17907 18735360 }
17908 287 }
17909
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 3 times.
292 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
17910 {
17911 3 combobuf[0].walk = 0xF0;
17912 3 combobuf[0].type = 0;
17913 3 combobuf[0].flag = 0;
17914 3 }
17915
17916 //Now for the new combo alias reset
17917
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 82 times.
292 if(section_version<2)
17918 {
17919
2/2
✓ Branch 0 taken 671744 times.
✓ Branch 1 taken 82 times.
671826 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
17920 {
17921 671744 combo_aliases[j].width = 0;
17922 671744 combo_aliases[j].height = 0;
17923 671744 combo_aliases[j].layermask = 0;
17924
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].combos.clear();
17925
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].csets.clear();
17926 671744 }
17927 82 }
17928
17929
17930
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 setup_combo_animations();
17931
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 setup_combo_animations2();
17932 292 return 0;
17933 293 }
17934 1335452 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
17935 {
17936 byte combo_has_flags;
17937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1335452 times.
1335452 if(!p_getc(&combo_has_flags,f))
17938 return qe_invalid;
17939
17940 1335452 temp_combo.clear();
17941
2/2
✓ Branch 0 taken 706665 times.
✓ Branch 1 taken 628787 times.
1335452 if(combo_has_flags)
17942 {
17943
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 628730 times.
628787 if(combo_has_flags&CHAS_BASIC)
17944 {
17945
1/2
✓ Branch 0 taken 628730 times.
✗ Branch 1 not taken.
628730 if(!p_igetl(&temp_combo.tile,f))
17946 return qe_invalid;
17947 628730 temp_combo.o_tile = temp_combo.tile;
17948
17949
1/2
✓ Branch 0 taken 628730 times.
✗ Branch 1 not taken.
628730 if(!p_getc(&temp_combo.flip,f))
17950 return qe_invalid;
17951
17952
1/2
✓ Branch 0 taken 628730 times.
✗ Branch 1 not taken.
628730 if(!p_getc(&temp_combo.walk,f))
17953 return qe_invalid;
17954
17955
1/2
✓ Branch 0 taken 628730 times.
✗ Branch 1 not taken.
628730 if(!p_getc(&temp_combo.type,f))
17956 return qe_invalid;
17957
17958
1/2
✓ Branch 0 taken 628730 times.
✗ Branch 1 not taken.
628730 if(!p_getc(&temp_combo.flag,f))
17959 return qe_invalid;
17960
17961
1/2
✓ Branch 0 taken 628730 times.
✗ Branch 1 not taken.
628730 if(!p_getc(&temp_combo.csets,f))
17962 return qe_invalid;
17963 628730 }
17964
2/2
✓ Branch 0 taken 625966 times.
✓ Branch 1 taken 2821 times.
628787 if(combo_has_flags&CHAS_SCRIPT)
17965 {
17966
2/2
✓ Branch 0 taken 2791 times.
✓ Branch 1 taken 30 times.
2821 if (s_version>=41)
17967 {
17968 2791 p_getcstr(&temp_combo.label, f);
17969 2791 }
17970 else
17971 {
17972 char label[12];
17973 30 label[11] = '\0';
17974
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 30 times.
360 for ( int32_t q = 0; q < 11; q++ )
17975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330 times.
330 if(!p_getc(&label[q],f))
17976 return qe_invalid;
17977 30 temp_combo.label = label;
17978 }
17979
17980
1/2
✓ Branch 0 taken 2821 times.
✗ Branch 1 not taken.
2821 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
17981 2821 auto initd_count = s_version >= 43 ? 8 : 2;
17982
2/2
✓ Branch 0 taken 22388 times.
✓ Branch 1 taken 2821 times.
25209 for ( int32_t q = 0; q < initd_count; q++ )
17983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22388 times.
22388 if(!p_igetl(&temp_combo.initd[q],f))
17984 return qe_invalid;
17985 2821 }
17986
2/2
✓ Branch 0 taken 507409 times.
✓ Branch 1 taken 121378 times.
628787 if(combo_has_flags&CHAS_ANIM)
17987 {
17988
1/2
✓ Branch 0 taken 121378 times.
✗ Branch 1 not taken.
121378 if(!p_getc(&temp_combo.frames,f))
17989 return qe_invalid;
17990
17991
1/2
✓ Branch 0 taken 121378 times.
✗ Branch 1 not taken.
121378 if(!p_getc(&temp_combo.speed,f))
17992 return qe_invalid;
17993
17994
1/2
✓ Branch 0 taken 121378 times.
✗ Branch 1 not taken.
121378 if(!p_igetw(&temp_combo.nextcombo,f))
17995 return qe_invalid;
17996
17997
1/2
✓ Branch 0 taken 121378 times.
✗ Branch 1 not taken.
121378 if(!p_getc(&temp_combo.nextcset,f))
17998 return qe_invalid;
17999
18000
1/2
✓ Branch 0 taken 121378 times.
✗ Branch 1 not taken.
121378 if(!p_getc(&temp_combo.skipanim,f))
18001 return qe_invalid;
18002
18003
1/2
✓ Branch 0 taken 121378 times.
✗ Branch 1 not taken.
121378 if(!p_getc(&temp_combo.skipanimy,f))
18004 return qe_invalid;
18005
18006
1/2
✓ Branch 0 taken 121378 times.
✗ Branch 1 not taken.
121378 if(!p_getc(&temp_combo.animflags,f))
18007 return qe_invalid;
18008 121378 }
18009
2/2
✓ Branch 0 taken 577604 times.
✓ Branch 1 taken 51183 times.
628787 if(combo_has_flags&CHAS_ATTRIB)
18010 {
18011
2/2
✓ Branch 0 taken 204732 times.
✓ Branch 1 taken 51183 times.
255915 for ( int32_t q = 0; q < 4; q++ )
18012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204732 times.
204732 if(!p_igetl(&temp_combo.attributes[q],f))
18013 return qe_invalid;
18014
2/2
✓ Branch 0 taken 409464 times.
✓ Branch 1 taken 51183 times.
460647 for ( int32_t q = 0; q < 8; q++ )
18015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 409464 times.
409464 if(!p_getc(&temp_combo.attribytes[q],f))
18016 return qe_invalid;
18017
2/2
✓ Branch 0 taken 409464 times.
✓ Branch 1 taken 51183 times.
460647 for ( int32_t q = 0; q < 8; q++ )
18018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 409464 times.
409464 if(!p_igetw(&temp_combo.attrishorts[q],f))
18019 return qe_invalid;
18020 51183 }
18021
2/2
✓ Branch 0 taken 618020 times.
✓ Branch 1 taken 10767 times.
628787 if(combo_has_flags&CHAS_FLAG)
18022 {
18023
1/2
✓ Branch 0 taken 10767 times.
✗ Branch 1 not taken.
10767 if(!p_igetl(&temp_combo.usrflags,f))
18024 return qe_invalid;
18025
1/2
✓ Branch 0 taken 10767 times.
✗ Branch 1 not taken.
10767 if(!p_igetw(&temp_combo.genflags,f))
18026 return qe_invalid;
18027 10767 }
18028
2/2
✓ Branch 0 taken 616841 times.
✓ Branch 1 taken 11946 times.
628787 if(combo_has_flags&CHAS_TRIG)
18029 {
18030 11946 int numtrigs = s_version < 36 ? 3 : 6;
18031
2/2
✓ Branch 0 taken 70818 times.
✓ Branch 1 taken 11946 times.
82764 for ( int32_t q = 0; q < numtrigs; q++ )
18032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70818 times.
70818 if(!p_igetl(&temp_combo.triggerflags[q],f))
18033 return qe_invalid;
18034
1/2
✓ Branch 0 taken 11946 times.
✗ Branch 1 not taken.
11946 if(!p_igetl(&temp_combo.triggerlevel,f))
18035 return qe_invalid;
18036
1/2
✓ Branch 0 taken 11946 times.
✗ Branch 1 not taken.
11946 if(!p_getc(&temp_combo.triggerbtn,f))
18037 return qe_invalid;
18038
1/2
✓ Branch 0 taken 11946 times.
✗ Branch 1 not taken.
11946 if(!p_getc(&temp_combo.triggeritem,f))
18039 return qe_invalid;
18040
1/2
✓ Branch 0 taken 11946 times.
✗ Branch 1 not taken.
11946 if(!p_getc(&temp_combo.trigtimer,f))
18041 return qe_invalid;
18042
1/2
✓ Branch 0 taken 11946 times.
✗ Branch 1 not taken.
11946 if(!p_getc(&temp_combo.trigsfx,f))
18043 return qe_invalid;
18044
1/2
✓ Branch 0 taken 11946 times.
✗ Branch 1 not taken.
11946 if(!p_igetl(&temp_combo.trigchange,f))
18045 return qe_invalid;
18046
1/2
✓ Branch 0 taken 11946 times.
✗ Branch 1 not taken.
11946 if(!p_igetw(&temp_combo.trigprox,f))
18047 return qe_invalid;
18048
1/2
✓ Branch 0 taken 11946 times.
✗ Branch 1 not taken.
11946 if(!p_getc(&temp_combo.trigctr,f))
18049 return qe_invalid;
18050
1/2
✓ Branch 0 taken 11946 times.
✗ Branch 1 not taken.
11946 if(!p_igetl(&temp_combo.trigctramnt,f))
18051 return qe_invalid;
18052
1/2
✓ Branch 0 taken 11946 times.
✗ Branch 1 not taken.
11946 if(!p_getc(&temp_combo.triglbeam,f))
18053 return qe_invalid;
18054
1/2
✓ Branch 0 taken 11946 times.
✗ Branch 1 not taken.
11946 if(!p_getc(&temp_combo.trigcschange,f))
18055 return qe_invalid;
18056
1/2
✓ Branch 0 taken 11946 times.
✗ Branch 1 not taken.
11946 if(!p_igetw(&temp_combo.spawnitem,f))
18057 return qe_invalid;
18058
1/2
✓ Branch 0 taken 11946 times.
✗ Branch 1 not taken.
11946 if(!p_igetw(&temp_combo.spawnenemy,f))
18059 return qe_invalid;
18060
1/2
✓ Branch 0 taken 11946 times.
✗ Branch 1 not taken.
11946 if(!p_getc(&temp_combo.exstate,f))
18061 return qe_invalid;
18062
1/2
✓ Branch 0 taken 11946 times.
✗ Branch 1 not taken.
11946 if(!p_igetl(&temp_combo.spawnip,f))
18063 return qe_invalid;
18064
1/2
✓ Branch 0 taken 11946 times.
✗ Branch 1 not taken.
11946 if(!p_getc(&temp_combo.trigcopycat,f))
18065 return qe_invalid;
18066
1/2
✓ Branch 0 taken 11946 times.
✗ Branch 1 not taken.
11946 if(!p_getc(&temp_combo.trigcooldown,f))
18067 return qe_invalid;
18068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11946 times.
11946 if(s_version >= 35)
18069 {
18070
1/2
✓ Branch 0 taken 11946 times.
✗ Branch 1 not taken.
11946 if(!p_igetw(&temp_combo.prompt_cid,f))
18071 return qe_invalid;
18072
1/2
✓ Branch 0 taken 11946 times.
✗ Branch 1 not taken.
11946 if(!p_getc(&temp_combo.prompt_cs,f))
18073 return qe_invalid;
18074
1/2
✓ Branch 0 taken 11946 times.
✗ Branch 1 not taken.
11946 if(!p_igetw(&temp_combo.prompt_x,f))
18075 return qe_invalid;
18076
1/2
✓ Branch 0 taken 11946 times.
✗ Branch 1 not taken.
11946 if(!p_igetw(&temp_combo.prompt_y,f))
18077 return qe_invalid;
18078 11946 }
18079
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 11660 times.
11946 if(s_version >= 36)
18080 {
18081
1/2
✓ Branch 0 taken 11660 times.
✗ Branch 1 not taken.
11660 if(!p_getc(&temp_combo.trig_lstate,f))
18082 return qe_invalid;
18083
1/2
✓ Branch 0 taken 11660 times.
✗ Branch 1 not taken.
11660 if(!p_getc(&temp_combo.trig_gstate,f))
18084 return qe_invalid;
18085
1/2
✓ Branch 0 taken 11660 times.
✗ Branch 1 not taken.
11660 if(!p_igetl(&temp_combo.trig_statetime,f))
18086 return qe_invalid;
18087 11660 }
18088
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 11660 times.
11946 if(s_version >= 37)
18089 {
18090
1/2
✓ Branch 0 taken 11660 times.
✗ Branch 1 not taken.
11660 if(!p_igetw(&temp_combo.trig_genscr,f))
18091 return qe_invalid;
18092 11660 }
18093
2/2
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 11512 times.
11946 if(s_version >= 38)
18094 {
18095
1/2
✓ Branch 0 taken 11512 times.
✗ Branch 1 not taken.
11512 if(!p_getc(&temp_combo.trig_group,f))
18096 return qe_invalid;
18097
1/2
✓ Branch 0 taken 11512 times.
✗ Branch 1 not taken.
11512 if(!p_igetw(&temp_combo.trig_group_val,f))
18098 return qe_invalid;
18099 11512 }
18100
2/2
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 11476 times.
11946 if(s_version >= 45)
18101 {
18102
1/2
✓ Branch 0 taken 11476 times.
✗ Branch 1 not taken.
11476 if(!p_getc(&temp_combo.exdoor_dir,f))
18103 return qe_invalid;
18104
1/2
✓ Branch 0 taken 11476 times.
✗ Branch 1 not taken.
11476 if(!p_getc(&temp_combo.exdoor_ind,f))
18105 return qe_invalid;
18106 11476 }
18107
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 4834 times.
11946 if(s_version >= 46)
18108 {
18109
1/2
✓ Branch 0 taken 4834 times.
✗ Branch 1 not taken.
4834 if(!p_getc(&temp_combo.trig_levelitems,f))
18110 return qe_invalid;
18111
1/2
✓ Branch 0 taken 4834 times.
✗ Branch 1 not taken.
4834 if(!p_igetw(&temp_combo.trigdmlevel,f))
18112 return qe_invalid;
18113
1/2
✓ Branch 0 taken 4834 times.
✗ Branch 1 not taken.
4834 if(s_version >= 48)
18114 {
18115
2/2
✓ Branch 0 taken 14502 times.
✓ Branch 1 taken 4834 times.
19336 for(int q = 0; q < 3; ++q)
18116
1/2
✓ Branch 0 taken 14502 times.
✗ Branch 1 not taken.
14502 if(!p_igetw(&temp_combo.trigtint[q],f))
18117 return qe_invalid;
18118 4834 }
18119 else
18120 {
18121 for(int q = 0; q < 3; ++q)
18122 if(!p_getc(&temp_combo.trigtint[q],f))
18123 return qe_invalid;
18124 for(int q = 0; q < 3; ++q)
18125 {
18126 int v = temp_combo.trigtint[q];
18127 int va = abs(v);
18128 temp_combo.trigtint[q] = _rgb_scale_6[va] * sign(v);
18129 }
18130 }
18131
1/2
✓ Branch 0 taken 4834 times.
✗ Branch 1 not taken.
4834 if(!p_igetw(&temp_combo.triglvlpalette,f))
18132 return qe_invalid;
18133
1/2
✓ Branch 0 taken 4834 times.
✗ Branch 1 not taken.
4834 if(!p_igetw(&temp_combo.trigbosspalette,f))
18134 return qe_invalid;
18135
1/2
✓ Branch 0 taken 4834 times.
✗ Branch 1 not taken.
4834 if(!p_igetw(&temp_combo.trigquaketime,f))
18136 return qe_invalid;
18137
1/2
✓ Branch 0 taken 4834 times.
✗ Branch 1 not taken.
4834 if(!p_igetw(&temp_combo.trigwavytime,f))
18138 return qe_invalid;
18139
1/2
✓ Branch 0 taken 4834 times.
✗ Branch 1 not taken.
4834 if(!p_igetw(&temp_combo.trig_swjinxtime,f))
18140 return qe_invalid;
18141
1/2
✓ Branch 0 taken 4834 times.
✗ Branch 1 not taken.
4834 if(!p_igetw(&temp_combo.trig_itmjinxtime,f))
18142 return qe_invalid;
18143
1/2
✓ Branch 0 taken 4834 times.
✗ Branch 1 not taken.
4834 if(!p_igetw(&temp_combo.trig_stuntime,f))
18144 return qe_invalid;
18145
1/2
✓ Branch 0 taken 4834 times.
✗ Branch 1 not taken.
4834 if(!p_igetw(&temp_combo.trig_bunnytime,f))
18146 return qe_invalid;
18147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4834 times.
4834 if(!p_getc(&temp_combo.trig_pushtime,f))
18148 return qe_invalid;
18149 4834 }
18150
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 4834 times.
11946 if(s_version >= 47)
18151 {
18152
1/2
✓ Branch 0 taken 4834 times.
✗ Branch 1 not taken.
4834 if (!p_igetw(&temp_combo.trig_shieldjinxtime, f))
18153 return qe_invalid;
18154 4834 }
18155 11946 }
18156
2/2
✓ Branch 0 taken 628283 times.
✓ Branch 1 taken 504 times.
628787 if(combo_has_flags&CHAS_LIFT)
18157 {
18158
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 if(!p_igetw(&temp_combo.liftcmb,f))
18159 return qe_invalid;
18160
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 if(!p_getc(&temp_combo.liftcs,f))
18161 return qe_invalid;
18162
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 if(!p_igetw(&temp_combo.liftundercmb,f))
18163 return qe_invalid;
18164
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 if(!p_getc(&temp_combo.liftundercs,f))
18165 return qe_invalid;
18166
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 if(!p_getc(&temp_combo.liftdmg,f))
18167 return qe_invalid;
18168
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 if(!p_getc(&temp_combo.liftlvl,f))
18169 return qe_invalid;
18170
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 if(!p_getc(&temp_combo.liftitm,f))
18171 return qe_invalid;
18172
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 if(!p_getc(&temp_combo.liftflags,f))
18173 return qe_invalid;
18174
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 if(!p_getc(&temp_combo.liftgfx,f))
18175 return qe_invalid;
18176
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 if(!p_getc(&temp_combo.liftsprite,f))
18177 return qe_invalid;
18178
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 if(!p_getc(&temp_combo.liftsfx,f))
18179 return qe_invalid;
18180
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 if(!p_igetw(&temp_combo.liftbreaksprite,f))
18181 return qe_invalid;
18182
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 if(!p_getc(&temp_combo.liftbreaksfx,f))
18183 return qe_invalid;
18184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 504 times.
504 if(s_version >= 34)
18185 {
18186
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 if(!p_getc(&temp_combo.lifthei,f))
18187 return qe_invalid;
18188
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 if(!p_getc(&temp_combo.lifttime,f))
18189 return qe_invalid;
18190 504 }
18191
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 490 times.
504 if(s_version >= 39)
18192 {
18193
1/2
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
490 if(!p_getc(&temp_combo.lift_parent_item,f))
18194 return qe_invalid;
18195 490 }
18196
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 388 times.
504 if(s_version >= 51)
18197 {
18198
1/2
✓ Branch 0 taken 388 times.
✗ Branch 1 not taken.
388 if(!p_getc(&temp_combo.liftlightrad,f))
18199 return qe_invalid;
18200
1/2
✓ Branch 0 taken 388 times.
✗ Branch 1 not taken.
388 if(!p_getc(&temp_combo.liftlightshape,f))
18201 return qe_invalid;
18202 388 }
18203 504 }
18204
2/2
✓ Branch 0 taken 599113 times.
✓ Branch 1 taken 29674 times.
628787 if(combo_has_flags&CHAS_GENERAL)
18205 {
18206
1/2
✓ Branch 0 taken 29674 times.
✗ Branch 1 not taken.
29674 if(!p_getc(&temp_combo.speed_mult,f))
18207 return qe_invalid;
18208
1/2
✓ Branch 0 taken 29674 times.
✗ Branch 1 not taken.
29674 if(!p_getc(&temp_combo.speed_div,f))
18209 return qe_invalid;
18210
1/2
✓ Branch 0 taken 29674 times.
✗ Branch 1 not taken.
29674 if(!p_igetzf(&temp_combo.speed_add,f))
18211 return qe_invalid;
18212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29674 times.
29674 if(s_version >= 42)
18213 {
18214
1/2
✓ Branch 0 taken 29674 times.
✗ Branch 1 not taken.
29674 if(!p_getc(&temp_combo.sfx_appear,f))
18215 return qe_invalid;
18216
1/2
✓ Branch 0 taken 29674 times.
✗ Branch 1 not taken.
29674 if(!p_getc(&temp_combo.sfx_disappear,f))
18217 return qe_invalid;
18218
1/2
✓ Branch 0 taken 29674 times.
✗ Branch 1 not taken.
29674 if(!p_getc(&temp_combo.sfx_loop,f))
18219 return qe_invalid;
18220
1/2
✓ Branch 0 taken 29674 times.
✗ Branch 1 not taken.
29674 if(!p_getc(&temp_combo.sfx_walking,f))
18221 return qe_invalid;
18222
1/2
✓ Branch 0 taken 29674 times.
✗ Branch 1 not taken.
29674 if(!p_getc(&temp_combo.sfx_standing,f))
18223 return qe_invalid;
18224
1/2
✓ Branch 0 taken 29674 times.
✗ Branch 1 not taken.
29674 if(!p_getc(&temp_combo.spr_appear,f))
18225 return qe_invalid;
18226
1/2
✓ Branch 0 taken 29674 times.
✗ Branch 1 not taken.
29674 if(!p_getc(&temp_combo.spr_disappear,f))
18227 return qe_invalid;
18228
1/2
✓ Branch 0 taken 29674 times.
✗ Branch 1 not taken.
29674 if(!p_getc(&temp_combo.spr_walking,f))
18229 return qe_invalid;
18230
1/2
✓ Branch 0 taken 29674 times.
✗ Branch 1 not taken.
29674 if(!p_getc(&temp_combo.spr_standing,f))
18231 return qe_invalid;
18232 29674 }
18233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29674 times.
29674 if(s_version >= 44)
18234 {
18235
1/2
✓ Branch 0 taken 29674 times.
✗ Branch 1 not taken.
29674 if(!p_getc(&temp_combo.sfx_tap,f))
18236 return qe_invalid;
18237 29674 }
18238
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 29308 times.
29674 if(s_version >= 49)
18239 {
18240
1/2
✓ Branch 0 taken 29308 times.
✗ Branch 1 not taken.
29308 if(!p_getc(&temp_combo.sfx_landing,f))
18241 return qe_invalid;
18242 29308 }
18243
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 29308 times.
29674 if(s_version >= 50)
18244 {
18245
1/2
✓ Branch 0 taken 29308 times.
✗ Branch 1 not taken.
29308 if(!p_getc(&temp_combo.spr_falling,f))
18246 return qe_invalid;
18247
1/2
✓ Branch 0 taken 29308 times.
✗ Branch 1 not taken.
29308 if(!p_getc(&temp_combo.spr_drowning,f))
18248 return qe_invalid;
18249
1/2
✓ Branch 0 taken 29308 times.
✗ Branch 1 not taken.
29308 if(!p_getc(&temp_combo.spr_lava_drowning,f))
18250 return qe_invalid;
18251
1/2
✓ Branch 0 taken 29308 times.
✗ Branch 1 not taken.
29308 if(!p_getc(&temp_combo.sfx_falling,f))
18252 return qe_invalid;
18253
1/2
✓ Branch 0 taken 29308 times.
✗ Branch 1 not taken.
29308 if(!p_getc(&temp_combo.sfx_drowning,f))
18254 return qe_invalid;
18255
1/2
✓ Branch 0 taken 29308 times.
✗ Branch 1 not taken.
29308 if(!p_getc(&temp_combo.sfx_lava_drowning,f))
18256 return qe_invalid;
18257 29308 }
18258 29674 }
18259 628787 }
18260 1335452 update_combo(temp_combo, s_version);
18261 1335452 return 0;
18262 1335452 }
18263
18264 467 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
18265 {
18266
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 24 times.
467 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
18267
18268 467 word section_version=0;
18269 467 word combos_used=0;
18270 int32_t dummy;
18271 byte padding;
18272 467 newcombo temp_combo;
18273
18274
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 466 times.
467 if (!should_skip)
18275 {
18276
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 reset_all_combo_animations();
18277
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 init_combo_classes();
18278
18279
2/2
✓ Branch 0 taken 30420480 times.
✓ Branch 1 taken 466 times.
30420946 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18280
1/2
✓ Branch 0 taken 30420480 times.
✗ Branch 1 not taken.
30420480 combobuf[q].clear();
18281 466 }
18282
18283
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 24 times.
467 if(version > 0x192) //Version info
18284 {
18285
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetw(&section_version,f))
18286 {
18287 return qe_invalid;
18288 }
18289 443 FFCore.quest_format[vCombos] = section_version;
18290
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!read_deprecated_section_cversion(f))
18291 {
18292 return qe_invalid;
18293 }
18294
18295 //section size
18296
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetl(&dummy,f))
18297 {
18298 return qe_invalid;
18299 }
18300 443 }
18301
18302
2/2
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 293 times.
467 if(section_version > 32) //Cleanup time!
18303 {
18304
2/4
✓ Branch 0 taken 174 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 174 times.
✗ Branch 3 not taken.
174 if(!p_igetw(&combos_used,f))
18305 {
18306 return qe_invalid;
18307 }
18308
2/2
✓ Branch 0 taken 1335452 times.
✓ Branch 1 taken 174 times.
1335626 for(int32_t i=0; i<combos_used; i++)
18309 {
18310
1/2
✓ Branch 0 taken 1335452 times.
✗ Branch 1 not taken.
1335452 auto ret = readcombo_loop(f,section_version,temp_combo);
18311
1/2
✓ Branch 0 taken 1335452 times.
✗ Branch 1 not taken.
1335452 if(ret) return ret;
18312
1/2
✓ Branch 0 taken 1335452 times.
✗ Branch 1 not taken.
1335452 if(i>=start_combo)
18313 {
18314
1/2
✓ Branch 0 taken 1335452 times.
✗ Branch 1 not taken.
1335452 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18315 {
18316 temp_combo.script = 0;
18317 for(int q = 0; q < 8; ++q)
18318 temp_combo.initd[q] = 0;
18319 }
18320
1/2
✓ Branch 0 taken 1335452 times.
✗ Branch 1 not taken.
1335452 combobuf[i] = temp_combo;
18321 1335452 }
18322 1335452 }
18323 174 }
18324 else //Call the old function for all old versions
18325 {
18326
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 293 times.
293 if(ret) return ret; //error, end read
18328 }
18329
18330
2/2
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 1 times.
467 if (should_skip)
18331 1 return 0;
18332
18333
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 165 times.
466 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18334 {
18335 165 combobuf[0].walk = 0xF0;
18336 165 combobuf[0].type = 0;
18337 165 combobuf[0].flag = 0;
18338 165 }
18339
18340
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 setup_combo_animations();
18341
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 setup_combo_animations2();
18342 466 return 0;
18343 467 }
18344
18345 384 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18346 {
18347 //these are here to bypass compiler warnings about unused arguments
18348 384 Header=Header;
18349 384 version=version;
18350 384 build=build;
18351
18352 int32_t dummy;
18353 384 word sversion=0, c_sversion;
18354
18355 //section version info
18356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_igetw(&sversion,f))
18357 {
18358 return qe_invalid;
18359 }
18360
18361 384 FFCore.quest_format[vComboAliases] = sversion;
18362
18363
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetw(&c_sversion,f))
18364 {
18365 return qe_invalid;
18366 }
18367
18368 //section size
18369
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetl(&dummy,f))
18370 {
18371 return qe_invalid;
18372 }
18373
18374 384 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18375
18376
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 205 times.
384 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18377 {
18378 205 max_num_combo_aliases = MAX250COMBOALIASES;
18379 205 }
18380
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18381 {
18382 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18383 }
18384
18385
2/2
✓ Branch 0 taken 1886208 times.
✓ Branch 1 taken 384 times.
1886592 for(int32_t j=0; j<max_num_combo_aliases; j++)
18386 {
18387 byte width,height,mask,tempcset;
18388 int32_t count;
18389 word tempword;
18390 byte tempbyte;
18391
18392
1/2
✓ Branch 0 taken 1886208 times.
✗ Branch 1 not taken.
1886208 if(!p_igetw(&tempword,f))
18393 {
18394 return qe_invalid;
18395 }
18396
18397 1886208 combo_aliases[j].combo = tempword;
18398
18399
1/2
✓ Branch 0 taken 1886208 times.
✗ Branch 1 not taken.
1886208 if(!p_getc(&tempbyte,f))
18400 {
18401 return qe_invalid;
18402 }
18403
18404 1886208 combo_aliases[j].cset = tempbyte;
18405
18406
1/2
✓ Branch 0 taken 1886208 times.
✗ Branch 1 not taken.
1886208 if(!p_getc(&width,f))
18407 {
18408 return qe_invalid;
18409 }
18410
18411
1/2
✓ Branch 0 taken 1886208 times.
✗ Branch 1 not taken.
1886208 if(!p_getc(&height,f))
18412 {
18413 return qe_invalid;
18414 }
18415
18416
1/2
✓ Branch 0 taken 1886208 times.
✗ Branch 1 not taken.
1886208 if(!p_getc(&mask,f))
18417 {
18418 return qe_invalid;
18419 }
18420
18421 1886208 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18422
18423 1886208 combo_aliases[j].width = width;
18424 1886208 combo_aliases[j].height = height;
18425 1886208 combo_aliases[j].layermask = mask;
18426 1886208 combo_aliases[j].combos.clear();
18427 1886208 combo_aliases[j].csets.clear();
18428
18429
2/2
✓ Branch 0 taken 1935950 times.
✓ Branch 1 taken 1886208 times.
3822158 for(int32_t k=0; k<count; k++)
18430 {
18431
1/2
✓ Branch 0 taken 1935950 times.
✗ Branch 1 not taken.
1935950 if(!p_igetw(&tempword,f))
18432 {
18433 return qe_invalid;
18434 }
18435
18436 1935950 combo_aliases[j].combos[k] = tempword;
18437 1935950 }
18438
18439
2/2
✓ Branch 0 taken 1935950 times.
✓ Branch 1 taken 1886208 times.
3822158 for(int32_t k=0; k<count; k++)
18440 {
18441
1/2
✓ Branch 0 taken 1935950 times.
✗ Branch 1 not taken.
1935950 if(!p_getc(&tempcset,f))
18442 {
18443 return qe_invalid;
18444 }
18445
18446 1935950 combo_aliases[j].csets[k] = tempcset;
18447 1935950 }
18448 1886208 }
18449
18450 //Combo pools!
18451 384 word num_combo_pools = 0;
18452
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 174 times.
384 if(sversion >= 4)
18453 {
18454
1/2
✓ Branch 0 taken 174 times.
✗ Branch 1 not taken.
174 if(!p_igetw(&num_combo_pools,f))
18455 {
18456 return qe_invalid;
18457 }
18458 174 }
18459
18460
2/2
✓ Branch 0 taken 3145728 times.
✓ Branch 1 taken 384 times.
3146112 for(combo_pool& pool : combo_pools)
18461 {
18462 3145728 pool.clear();
18463 }
18464
18465 384 combo_pool temp_cpool;
18466
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 384 times.
822 for(word cp = 0; cp < num_combo_pools; ++cp)
18467 {
18468 438 int32_t num_combos_in_pool = 0;
18469
2/4
✓ Branch 0 taken 438 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 438 times.
✗ Branch 3 not taken.
438 if(!p_igetl(&num_combos_in_pool,f))
18470 {
18471 return qe_invalid;
18472 }
18473
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 96 times.
438 if(num_combos_in_pool < 1) continue; //nothing to read
18474
18475
1/2
✓ Branch 0 taken 342 times.
✗ Branch 1 not taken.
342 temp_cpool.clear();
18476
18477 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18478
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 1550 times.
1892 for(auto q = 0; q < num_combos_in_pool; ++q)
18479 {
18480
2/4
✓ Branch 0 taken 1550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1550 times.
✗ Branch 3 not taken.
1550 if(!p_igetl(&cp_cid,f))
18481 {
18482 return qe_invalid;
18483 }
18484
2/4
✓ Branch 0 taken 1550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1550 times.
✗ Branch 3 not taken.
1550 if(!p_getc(&cp_cs,f))
18485 {
18486 return qe_invalid;
18487 }
18488
2/4
✓ Branch 0 taken 1550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1550 times.
✗ Branch 3 not taken.
1550 if(!p_igetw(&cp_quant,f))
18489 {
18490 return qe_invalid;
18491 }
18492
1/2
✓ Branch 0 taken 1550 times.
✗ Branch 1 not taken.
1550 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18493 1550 }
18494
18495
1/2
✓ Branch 0 taken 342 times.
✗ Branch 1 not taken.
342 combo_pools[cp] = temp_cpool;
18496 342 }
18497
18498 //Autocombos!
18499 384 word num_combo_autos = 0;
18500
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 222 times.
384 if (sversion >= 5)
18501 {
18502
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if (!p_igetw(&num_combo_autos, f))
18503 {
18504 return qe_invalid;
18505 }
18506 162 }
18507
18508
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 3145728 times.
3146112 for (combo_auto& cauto : combo_autos)
18509 {
18510
1/2
✓ Branch 0 taken 3145728 times.
✗ Branch 1 not taken.
3145728 cauto.clear(true);
18511 }
18512
18513
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 combo_auto temp_cauto;
18514
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 384 times.
459 for (word ca = 0; ca < num_combo_autos; ++ca)
18515 {
18516 byte type;
18517 int32_t display_cid, erase_cid;
18518 byte flags, arg;
18519
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if (!p_getc(&type, f))
18520 {
18521 return qe_invalid;
18522 }
18523
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if (!p_igetl(&display_cid, f))
18524 {
18525 return qe_invalid;
18526 }
18527
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if (!p_igetl(&erase_cid, f))
18528 {
18529 return qe_invalid;
18530 }
18531
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if (!p_getc(&flags, f))
18532 {
18533 return qe_invalid;
18534 }
18535
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if (!p_getc(&arg, f))
18536 {
18537 return qe_invalid;
18538 }
18539 75 int32_t num_combos_in_cauto = 0;
18540
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if (!p_igetl(&num_combos_in_cauto, f))
18541 {
18542 return qe_invalid;
18543 }
18544
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if (num_combos_in_cauto < 1) continue; //nothing to read
18545
18546
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cauto.clear();
18547
18548
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cauto.setType(type);
18549
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cauto.setDisplay(display_cid);
18550
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cauto.setEraseCombo(erase_cid);
18551
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cauto.setFlags(flags);
18552
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cauto.setArg(arg);
18553
18554 int32_t ca_cid; byte ca_ctype; int16_t ca_offset; int16_t ca_engrave_offset;
18555
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 930 times.
1005 for (auto q = 0; q < num_combos_in_cauto; ++q)
18556 {
18557
2/4
✓ Branch 0 taken 930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 930 times.
✗ Branch 3 not taken.
930 if (!p_getc(&ca_ctype, f))
18558 {
18559 return qe_invalid;
18560 }
18561
2/4
✓ Branch 0 taken 930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 930 times.
✗ Branch 3 not taken.
930 if (!p_igetl(&ca_cid, f))
18562 {
18563 return qe_invalid;
18564 }
18565
1/2
✓ Branch 0 taken 930 times.
✗ Branch 1 not taken.
930 temp_cauto.addEntry(ca_cid, ca_ctype, q, -1);
18566 930 }
18567
18568
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 combo_autos[ca] = temp_cauto;
18569 75 }
18570
18571 384 return 0;
18572 384 }
18573
18574 781 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
18575 {
18576
2/2
✓ Branch 0 taken 757 times.
✓ Branch 1 taken 24 times.
781 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_colors);
18577
18578 //these are here to bypass compiler warnings about unused arguments
18579 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18580 //Capitalized cause it'll save you a headache. -Deedee
18581 781 start_cset=start_cset;
18582 781 max_csets=max_csets;
18583 781 word s_version=0;
18584
18585 miscQdata temp_misc;
18586 781 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18587
18588 byte temp_colordata[48];
18589 char temp_palname[PALNAMESIZE+1];
18590
18591 int32_t dummy;
18592 word palcycles;
18593
18594
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 757 times.
781 if(version > 0x192)
18595 {
18596 //section version info
18597
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 if(!p_igetw(&s_version,f))
18598 {
18599 return qe_invalid;
18600 }
18601
18602 757 FFCore.quest_format[vCSets] = s_version;
18603
18604
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 if(!p_igetw(&dummy,f))
18605 {
18606 return qe_invalid;
18607 }
18608
18609 //section size
18610
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 if(!p_igetl(&dummy,f))
18611 {
18612 return qe_invalid;
18613 }
18614 757 }
18615
2/2
✓ Branch 0 taken 602 times.
✓ Branch 1 taken 179 times.
781 if (s_version < 5)
18616 {
18617
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 584 times.
✓ Branch 2 taken 578 times.
✓ Branch 3 taken 6 times.
602 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18618
18619 //finally... section data
18620 602 int32_t q = 0;
18621 602 int32_t p = -15;
18622
2/2
✓ Branch 0 taken 144480 times.
✓ Branch 1 taken 602 times.
145082 for(int32_t i=0; i<oldpdTOTAL; ++i)
18623 {
18624 144480 memset(temp_colordata, 0, 48);
18625
18626
1/2
✓ Branch 0 taken 144480 times.
✗ Branch 1 not taken.
144480 if(!pfread(temp_colordata,48,f))
18627 {
18628 return qe_invalid;
18629 }
18630
18631
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 144240 times.
144480 if (should_skip)
18632 240 continue;
18633
18634 144240 memcpy(&colordata[q*48], temp_colordata, 48);
18635
18636 144240 ++q;
18637
8/8
✓ Branch 0 taken 134624 times.
✓ Branch 1 taken 9616 times.
✓ Branch 2 taken 10217 times.
✓ Branch 3 taken 124407 times.
✓ Branch 4 taken 1202 times.
✓ Branch 5 taken 9015 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 1166 times.
144240 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18638 {
18639
1/2
✓ Branch 0 taken 10181 times.
✗ Branch 1 not taken.
10181 if (s_version < 5) //Bumping up the size of level palettes
18640 {
18641 10181 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18642 10181 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18643 10181 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18644 10181 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18645 10181 q+=4;
18646 10181 }
18647 else
18648 {
18649 for(int m = 0; m < 4; ++m)
18650 {
18651 memset(temp_colordata, 0, 48);
18652 if(!pfread(temp_colordata,48,f))
18653 {
18654 return qe_invalid;
18655 }
18656 memcpy(&colordata[q*48], temp_colordata, 48);
18657 ++q;
18658 }
18659 }
18660 10181 }
18661 144240 ++p;
18662 144240 }
18663
18664
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 584 times.
602 if(RealOldVerion)
18665 {
18666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
18667 {
18668 18 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18669 18 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18670 18 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18671 18 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18672 18 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18673 18 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18674 18 }
18675 18 }
18676 else
18677 {
18678 584 memset(temp_colordata, 0, 48);
18679
18680
2/2
✓ Branch 0 taken 1829672 times.
✓ Branch 1 taken 584 times.
1830256 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18681 {
18682
1/2
✓ Branch 0 taken 1829672 times.
✗ Branch 1 not taken.
1829672 if(!pfread(temp_colordata,48,f))
18683 {
18684 return qe_invalid;
18685 }
18686
18687
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 1826539 times.
1829672 if (should_skip)
18688 3133 continue;
18689
18690 1826539 memcpy(&colordata[q*48], temp_colordata, 48);
18691
18692 1826539 ++q;
18693
7/8
✓ Branch 0 taken 1826539 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140503 times.
✓ Branch 3 taken 1686036 times.
✓ Branch 4 taken 1166 times.
✓ Branch 5 taken 139337 times.
✓ Branch 6 taken 1038 times.
✓ Branch 7 taken 128 times.
1826539 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18694 {
18695
1/2
✓ Branch 0 taken 140375 times.
✗ Branch 1 not taken.
140375 if (s_version < 5) //Bumping up the size of level palettes
18696 {
18697 140375 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18698 140375 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18699 140375 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18700 140375 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18701 140375 q+=4;
18702 140375 }
18703 else
18704 {
18705 for(int m = 0; m < 4; ++m)
18706 {
18707 memset(temp_colordata, 0, 48);
18708 if(!pfread(temp_colordata,48,f))
18709 {
18710 return qe_invalid;
18711 }
18712 memcpy(&colordata[q*48], temp_colordata, 48);
18713 ++q;
18714 }
18715 }
18716 140375 }
18717 1826539 ++p;
18718 1826539 }
18719
18720
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 519 times.
584 if(s_version < 4)
18721 {
18722
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 64 times.
65 if (!should_skip)
18723 {
18724 64 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18725 64 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18726 64 }
18727 65 }
18728 else
18729 {
18730
2/2
✓ Branch 0 taken 1727232 times.
✓ Branch 1 taken 519 times.
1727751 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18731 {
18732
1/2
✓ Branch 0 taken 1727232 times.
✗ Branch 1 not taken.
1727232 if(!pfread(temp_colordata,48,f))
18733 {
18734 return qe_invalid;
18735 }
18736
18737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1727232 times.
1727232 if (should_skip)
18738 continue;
18739
18740 1727232 memcpy(&colordata[q*48], temp_colordata, 48);
18741 1727232 ++q;
18742
5/6
✓ Branch 0 taken 1727232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132864 times.
✓ Branch 3 taken 1594368 times.
✓ Branch 4 taken 1038 times.
✓ Branch 5 taken 131826 times.
1727232 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18743 {
18744
1/2
✓ Branch 0 taken 131826 times.
✗ Branch 1 not taken.
131826 if (s_version < 5) //Bumping up the size of level palettes
18745 {
18746 131826 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18747 131826 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18748 131826 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18749 131826 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18750 131826 q+=4;
18751 131826 }
18752 else
18753 {
18754 for(int m = 0; m < 4; ++m)
18755 {
18756 memset(temp_colordata, 0, 48);
18757 if(!pfread(temp_colordata,48,f))
18758 {
18759 return qe_invalid;
18760 }
18761 memcpy(&colordata[q*48], temp_colordata, 48);
18762 ++q;
18763 }
18764 }
18765 131826 }
18766 1727232 ++p;
18767 1727232 }
18768
18769 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18770 }
18771 }
18772 602 }
18773 else
18774 {
18775
2/2
✓ Branch 0 taken 1566071 times.
✓ Branch 1 taken 179 times.
1566250 for(int32_t i=0; i<pdTOTAL255; ++i)
18776 {
18777 1566071 memset(temp_colordata, 0, 48);
18778
18779
1/2
✓ Branch 0 taken 1566071 times.
✗ Branch 1 not taken.
1566071 if(!pfread(temp_colordata,48,f))
18780 {
18781 return qe_invalid;
18782 }
18783
18784 1566071 memcpy(&colordata[i*48], temp_colordata, 48);
18785 1566071 }
18786 }
18787
18788
4/4
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 134 times.
✓ Branch 3 taken 646 times.
781 if (!should_skip && s_version < 6)
18789 {
18790
2/2
✓ Branch 0 taken 271288992 times.
✓ Branch 1 taken 646 times.
271289638 for (int i = 0; i < psTOTAL255; i++)
18791 {
18792 271288992 colordata[i] = _rgb_scale_6[colordata[i]];
18793 271288992 }
18794 646 }
18795
18796
5/6
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 757 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
781 if((version < 0x192)||((version == 0x192)&&(build<76)))
18797 {
18798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
18799 18 init_palnames();
18800 18 }
18801 else
18802 {
18803 763 int32_t palnamestoread = 0;
18804
18805
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 698 times.
763 if(s_version < 3)
18806 65 palnamestoread = OLDMAXLEVELS;
18807 else
18808 698 palnamestoread = 512;
18809
18810
2/2
✓ Branch 0 taken 374016 times.
✓ Branch 1 taken 763 times.
374779 for(int32_t i=0; i<palnamestoread; ++i)
18811 {
18812
1/2
✓ Branch 0 taken 374016 times.
✗ Branch 1 not taken.
374016 if(!p_getstr(temp_palname,PALNAMESIZE,f))
18813 {
18814 return qe_invalid;
18815 }
18816
18817
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 373760 times.
374016 if (!should_skip)
18818 373760 memcpy(palnames[i], temp_palname, PALNAMESIZE);
18819 374016 }
18820
18821
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 762 times.
763 if (should_skip)
18822 1 return 0;
18823
18824
2/2
✓ Branch 0 taken 16384 times.
✓ Branch 1 taken 762 times.
17146 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
18825 {
18826 16384 memset(palnames[i], 0, PALNAMESIZE);
18827 16384 }
18828 }
18829
18830
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 757 times.
780 if(version > 0x192)
18831 {
18832
2/2
✓ Branch 0 taken 193792 times.
✓ Branch 1 taken 757 times.
194549 for(int32_t i=0; i<256; i++)
18833 {
18834
2/2
✓ Branch 0 taken 581376 times.
✓ Branch 1 taken 193792 times.
775168 for(int32_t j=0; j<3; j++)
18835 {
18836 581376 temp_misc.cycles[i][j].first=0;
18837 581376 temp_misc.cycles[i][j].count=0;
18838 581376 temp_misc.cycles[i][j].speed=0;
18839 581376 }
18840 193792 }
18841
18842
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 if(!p_igetw(&palcycles,f))
18843 {
18844 return qe_invalid;
18845 }
18846
18847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 757 times.
757 if (palcycles > NUM_PAL_CYCLES)
18848 {
18849 return qe_invalid;
18850 }
18851
18852
2/2
✓ Branch 0 taken 22060 times.
✓ Branch 1 taken 757 times.
22817 for(int32_t i=0; i<palcycles; i++)
18853 {
18854
2/2
✓ Branch 0 taken 66180 times.
✓ Branch 1 taken 22060 times.
88240 for(int32_t j=0; j<3; j++)
18855 {
18856
1/2
✓ Branch 0 taken 66180 times.
✗ Branch 1 not taken.
66180 if(!p_getc(&temp_misc.cycles[i][j].first,f))
18857 {
18858 return qe_invalid;
18859 }
18860 66180 }
18861
18862
2/2
✓ Branch 0 taken 66180 times.
✓ Branch 1 taken 22060 times.
88240 for(int32_t j=0; j<3; j++)
18863 {
18864
1/2
✓ Branch 0 taken 66180 times.
✗ Branch 1 not taken.
66180 if(!p_getc(&temp_misc.cycles[i][j].count,f))
18865 {
18866 return qe_invalid;
18867 }
18868 66180 }
18869
18870
2/2
✓ Branch 0 taken 66180 times.
✓ Branch 1 taken 22060 times.
88240 for(int32_t j=0; j<3; j++)
18871 {
18872
1/2
✓ Branch 0 taken 66180 times.
✗ Branch 1 not taken.
66180 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
18873 {
18874 return qe_invalid;
18875 }
18876 66180 }
18877 22060 }
18878
18879 757 memcpy(Misc, &temp_misc, sizeof(temp_misc));
18880 757 }
18881
18882 780 return 0;
18883 781 }
18884
18885 781 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
18886 {
18887
2/2
✓ Branch 0 taken 757 times.
✓ Branch 1 taken 24 times.
781 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_tiles);
18888
18889 781 int32_t tiles_used=0;
18890 781 word section_version = 0;
18891 781 int32_t section_size= 0;
18892 781 byte *temp_tile = new byte[tilesize(tf32Bit)];
18893
18894 //Tile Expansion
18895 //if ( version >= 0x254 && build >= 41 )
18896
4/4
✓ Branch 0 taken 602 times.
✓ Branch 1 taken 179 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 596 times.
781 if (version < 0x254 && build < 41)
18897 {
18898 596 max_tiles = ZC250MAXTILES;
18899 596 }
18900
18901
18902
2/6
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 781 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
781 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
18903 {
18904 if(!init_tiles_for_190(true, Header))
18905 {
18906 al_trace("Unable to initialize tiles\n");
18907 }
18908
18909 delete[] temp_tile;
18910 temp_tile=NULL;
18911 return 0;
18912 }
18913 else
18914 {
18915
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 757 times.
781 if(version > 0x192)
18916 {
18917 //section version info
18918
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 if(!p_igetw(&section_version,f))
18919 {
18920 delete[] temp_tile;
18921 return qe_invalid;
18922 }
18923
18924 757 FFCore.quest_format[vTiles] = section_version;
18925
18926
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 if(!read_deprecated_section_cversion(f))
18927 {
18928 delete[] temp_tile;
18929 return qe_invalid;
18930 }
18931
18932 //section size
18933
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 if(!p_igetl(&section_size,f))
18934 {
18935 delete[] temp_tile;
18936 return qe_invalid;
18937 }
18938 757 }
18939
18940 //if ( build < 41 )
18941 //{
18942 // tiles_used = ZC250MAXTILES;
18943 //}
18944
18945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 781 times.
781 if(version < 0x174)
18946 {
18947 tiles_used=TILES_PER_PAGE*4;
18948 } //no expanded tile space
18949
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 763 times.
781 else if(version < 0x191)
18950 {
18951 18 tiles_used=OLDMAXTILES;
18952 18 }
18953 else
18954 {
18955 //finally... section data
18956
3/4
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 584 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 179 times.
763 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
18957 {
18958
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(!p_igetl(&tiles_used,f))
18959 {
18960 delete[] temp_tile;
18961 return qe_invalid;
18962 }
18963 179 }
18964 else
18965 {
18966
1/2
✓ Branch 0 taken 584 times.
✗ Branch 1 not taken.
584 if(!p_igetw(&tiles_used,f))
18967 {
18968 delete[] temp_tile;
18969 return qe_invalid;
18970 }
18971 }
18972 }
18973
18974
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 tiles_used=zc_min(tiles_used, max_tiles);
18975
18976 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
18977 //if ( version < 0x254 && build < 41 )
18978
3/6
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 602 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 179 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
781 if ( version < 0x254 || (version == 0x254 && build < 41) )
18979 //if ( build < 41 )
18980 {
18981
1/2
✓ Branch 0 taken 602 times.
✗ Branch 1 not taken.
602 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
18982 602 }
18983 else //2.55
18984 {
18985
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
18986 }
18987
18988 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
18989
18990
18991
2/2
✓ Branch 0 taken 18008281 times.
✓ Branch 1 taken 781 times.
18009062 for(int32_t i=0; i<tiles_used; ++i)
18992 {
18993 18008281 byte format=tf4Bit;
18994 18008281 memset(temp_tile, 0, tilesize(tf32Bit));
18995
18996
3/6
✓ Branch 0 taken 2985456 times.
✓ Branch 1 taken 15022825 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2985456 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18008281 if((version>0x211)||((version==0x211)&&(build>4)))
18997 {
18998
1/2
✓ Branch 0 taken 15022825 times.
✗ Branch 1 not taken.
15022825 if(!p_getc(&format,f))
18999 {
19000 delete[] temp_tile;
19001 return qe_invalid;
19002 }
19003 15022825 }
19004
4/4
✓ Branch 0 taken 6826600 times.
✓ Branch 1 taken 11181681 times.
✓ Branch 2 taken 3123018 times.
✓ Branch 3 taken 3703582 times.
18008281 if(section_version > 2 && !format)
19005 {
19006 3703582 reset_tile(buf,start_tile+i,tf4Bit);
19007 3703582 continue;
19008 }
19009
19010
2/2
✓ Branch 0 taken 13815512 times.
✓ Branch 1 taken 489187 times.
14304699 int size = format == tf4Bit ? 128 : tilesize(format);
19011
1/2
✓ Branch 0 taken 14304699 times.
✗ Branch 1 not taken.
14304699 if(!pfread(temp_tile,size,f))
19012 {
19013 delete[] temp_tile;
19014 return qe_invalid;
19015 }
19016
19017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14304699 times.
14304699 if (should_skip)
19018 continue;
19019
19020 14304699 buf[start_tile+i].format=format;
19021
19022
2/2
✓ Branch 0 taken 14100814 times.
✓ Branch 1 taken 203885 times.
14304699 if(buf[start_tile+i].data)
19023 {
19024 14100814 free(buf[start_tile+i].data);
19025 14100814 buf[start_tile+i].data=NULL;
19026 14100814 }
19027
19028 14304699 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19029
19030
2/2
✓ Branch 0 taken 13815512 times.
✓ Branch 1 taken 489187 times.
14304699 if (format == tf4Bit)
19031 {
19032 byte temp[256];
19033 13815512 byte *si = temp_tile + 128;
19034 13815512 byte *di = temp + 256;
19035
19036
2/2
✓ Branch 0 taken 1768385536 times.
✓ Branch 1 taken 13815512 times.
1782201048 for(int i=127; i>=0; --i)
19037 {
19038 1768385536 (*(--di)) = (*(--si)) >> 4;
19039 1768385536 (*(--di)) = (*si) & 15;
19040 1768385536 }
19041
19042 13815512 memcpy(buf[start_tile+i].data,temp,256);
19043 13815512 }
19044 else
19045 {
19046 489187 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19047 }
19048 14304699 }
19049 }
19050
19051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 781 times.
781 if (should_skip)
19052 return 0;
19053
19054
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 602 times.
781 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19055 {
19056
2/2
✓ Branch 0 taken 89685960 times.
✓ Branch 1 taken 602 times.
89686562 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19057 {
19058
19059 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19060 89685960 reset_tile(buf,q,tf4Bit);
19061
19062
19063 /*
19064
19065 byte tempbyte;
19066 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19067 {
19068 tempbyte=buf[ZC250MAXTILES-1].data[i];
19069 buf[q].data[i] = tempbyte;
19070 }
19071 //int32_t temp = tempbyte=buf[130].data[i];
19072 //buf[q].data = buf[ZC250MAXTILES-1].data;
19073 */
19074 //reset_tile(buf,q,tf4Bit);
19075 89685960 }
19076
19077 602 }
19078
19079
4/6
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 602 times.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 179 times.
781 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19080 {
19081
2/2
✓ Branch 0 taken 29728955 times.
✓ Branch 1 taken 602 times.
29729557 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19082 {
19083 29728955 reset_tile(buf,i,tf4Bit);
19084 29728955 }
19085 602 }
19086 else
19087 {
19088
2/2
✓ Branch 0 taken 30995184 times.
✓ Branch 1 taken 179 times.
30995363 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19089 {
19090 30995184 reset_tile(buf,i,tf4Bit);
19091 30995184 }
19092 }
19093
19094
5/6
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 757 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
781 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19095 {
19096
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(get_qr(qr_BSZELDA)) //
19097 {
19098 byte tempbyte;
19099 6 int32_t floattile=wpnsbuf[iwSwim].tile;
19100
19101
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19102 {
19103 1536 tempbyte=buf[23].data[i];
19104 1536 buf[23].data[i]=buf[24].data[i];
19105 1536 buf[24].data[i]=buf[25].data[i];
19106 1536 buf[25].data[i]=buf[26].data[i];
19107 1536 buf[26].data[i]=tempbyte;
19108 1536 }
19109 //swim tiles are out of order, too, but nobody cared? -Z
19110
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19111 {
19112 1536 tempbyte=buf[floattile+11].data[i];
19113 1536 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19114 1536 buf[floattile+12].data[i]=tempbyte;
19115 1536 }
19116 6 }
19117 24 }
19118
19119
3/6
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 698 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
781 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19120 {
19121
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 22 times.
83 if(!get_qr(qr_NEWENEMYTILES))
19122 {
19123 byte tempbyte;
19124
19125
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19126 {
19127 5632 tempbyte=buf[130].data[i];
19128 5632 buf[130].data[i]=buf[132].data[i];
19129 5632 buf[132].data[i]=tempbyte;
19130
19131 5632 tempbyte=buf[131].data[i];
19132 5632 buf[131].data[i]=buf[133].data[i];
19133 5632 buf[133].data[i]=tempbyte;
19134 5632 }
19135 22 }
19136 83 }
19137
19138 781 al_trace("Registering blank tiles\n");
19139 781 register_blank_tiles();
19140
19141 //memset(temp_tile, 0, tilesize(tf32Bit));
19142
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 delete[] temp_tile;
19143 781 temp_tile=NULL;
19144 781 return 0;
19145 781 }
19146
19147 466 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
19148 {
19149
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 23 times.
466 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_midis);
19150
19151 static byte fake_midi_flags[32];
19152
19153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 466 times.
466 byte *mf=should_skip ? fake_midi_flags : midi_flags;
19154 int32_t dummy;
19155 word dummy2;
19156 // zcmidi_ temp_midi;
19157 int32_t tunes_to_read;
19158 466 int32_t tune_count=0;
19159 466 word section_version=0;
19160 466 zctune temp;
19161
19162
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 443 times.
466 if(Header->zelda_version < 0x193)
19163 {
19164 // mf=Header->data_flags+ZQ_MIDIS2;
19165
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
23 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19166 {
19167 22 tunes_to_read=MAXCUSTOMMIDIS192b177;
19168 22 }
19169 else
19170 {
19171 1 tunes_to_read=MAXCUSTOMTUNES;
19172 }
19173 23 }
19174 else
19175 {
19176 //section version info
19177
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetw(&section_version,f))
19178 {
19179 return qe_invalid;
19180 }
19181
19182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if (!should_skip)
19183 443 FFCore.quest_format[vMIDIs] = section_version;
19184
19185
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetw(&dummy2,f))
19186 {
19187 return qe_invalid;
19188 }
19189
19190 //section size
19191
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetl(&dummy,f))
19192 {
19193 return qe_invalid;
19194 }
19195
19196 //finally... section data
19197
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!pfread(midi_flags,sizeof(midi_flags),f))
19198 {
19199 return qe_invalid;
19200 }
19201
19202 443 tunes_to_read=MAXCUSTOMTUNES;
19203 }
19204
19205
2/2
✓ Branch 0 taken 117432 times.
✓ Branch 1 taken 466 times.
117898 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19206 {
19207
2/2
✓ Branch 0 taken 10238 times.
✓ Branch 1 taken 107194 times.
117432 if(get_bit(mf, i))
19208 {
19209 10238 ++tune_count;
19210 10238 }
19211 117432 }
19212
19213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 466 times.
466 if (!should_skip)
19214 466 reset_tunes(tunes); //reset_midis(midis);
19215
19216
2/2
✓ Branch 0 taken 112592 times.
✓ Branch 1 taken 466 times.
113058 for(int32_t i=0; i<tunes_to_read; i++)
19217 {
19218 112592 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19219
19220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112592 times.
112592 if (!should_skip)
19221 112592 tunes[i].reset(); // reset_midi(midis+i);
19222
19223
2/2
✓ Branch 0 taken 102354 times.
✓ Branch 1 taken 10238 times.
112592 if(get_bit(mf,i))
19224 {
19225
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7575 times.
10238 if(section_version < 4)
19226 {
19227
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if(!p_getstr(temp.title,20,f))
19228 {
19229 return qe_invalid;
19230 }
19231 2663 }
19232 else
19233 {
19234
1/2
✓ Branch 0 taken 7575 times.
✗ Branch 1 not taken.
7575 if(!p_getstr(temp.title,sizeof(temp.title)-1,f))
19235 {
19236 return qe_invalid;
19237 }
19238 }
19239
19240
1/2
✓ Branch 0 taken 10238 times.
✗ Branch 1 not taken.
10238 if(!p_igetl(&temp.start,f))
19241 {
19242 return qe_invalid;
19243 }
19244
19245
1/2
✓ Branch 0 taken 10238 times.
✗ Branch 1 not taken.
10238 if(!p_igetl(&temp.loop_start,f))
19246 {
19247 return qe_invalid;
19248 }
19249
19250
1/2
✓ Branch 0 taken 10238 times.
✗ Branch 1 not taken.
10238 if(!p_igetl(&temp.loop_end,f))
19251 {
19252 return qe_invalid;
19253 }
19254
19255
1/2
✓ Branch 0 taken 10238 times.
✗ Branch 1 not taken.
10238 if(!p_igetw(&temp.loop,f))
19256 {
19257 return qe_invalid;
19258 }
19259
19260
1/2
✓ Branch 0 taken 10238 times.
✗ Branch 1 not taken.
10238 if(!p_igetw(&temp.volume,f))
19261 {
19262 return qe_invalid;
19263 }
19264
19265
2/2
✓ Branch 0 taken 9989 times.
✓ Branch 1 taken 249 times.
10238 if(Header->zelda_version < 0x193)
19266 {
19267
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(!p_igetl(&dummy,f))
19268 {
19269 return qe_invalid;
19270 }
19271 249 }
19272
19273
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7575 times.
10238 if(section_version >= 3)
19274 {
19275
1/2
✓ Branch 0 taken 7575 times.
✗ Branch 1 not taken.
7575 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19276 {
19277 return qe_invalid;
19278 }
19279 7575 }
19280
19281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10238 times.
10238 if (!should_skip)
19282 10238 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19283
19284
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7575 times.
10238 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19285 {
19286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2663 times.
2663 if (should_skip)
19287 {
19288 if (read_midi(f)==NULL)
19289 {
19290 return qe_invalid;
19291 }
19292
19293 continue;
19294 }
19295
19296 // old format - a midi is a midi
19297
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if((tunes[i].data=read_midi(f))==NULL)
19298 {
19299 return qe_invalid;
19300 }
19301 2663 }
19302 else
19303 {
19304 byte format;
19305
1/2
✓ Branch 0 taken 7575 times.
✗ Branch 1 not taken.
7575 if(!pfread(&format,sizeof(format),f))
19306 {
19307 return qe_invalid;
19308 }
19309
19310 // MIDI is the only format saved here.
19311 // Never did more than MIDI for a zctune, and no plans to now.
19312
1/2
✓ Branch 0 taken 7575 times.
✗ Branch 1 not taken.
7575 if (format != MFORMAT_MIDI)
19313 {
19314 return qe_invalid;
19315 }
19316
19317 7575 tunes[i].data = read_midi(f);
19318
1/2
✓ Branch 0 taken 7575 times.
✗ Branch 1 not taken.
7575 if (!tunes[i].data)
19319 {
19320 return qe_invalid;
19321 }
19322 }
19323 10238 }
19324 112592 }
19325
19326 466 return 0;
19327 466 }
19328
19329 466 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19330 {
19331
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 23 times.
466 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_cheats);
19332
19333 int32_t dummy;
19334 ZCHEATS tempzcheats;
19335 466 char temp_use_cheats=1;
19336 466 memset(&tempzcheats, 0, sizeof(tempzcheats));
19337 466 word s_version = 0;
19338
19339
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 443 times.
466 if(Header->zelda_version > 0x192)
19340 {
19341 //section version info
19342
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetw(&s_version,f))
19343 {
19344 return qe_invalid;
19345 }
19346
19347 443 FFCore.quest_format[vCheats] = s_version;
19348
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetw(&dummy,f))
19349 {
19350 return qe_invalid;
19351 }
19352
19353 //section size
19354
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetl(&dummy,f))
19355 {
19356 return qe_invalid;
19357 }
19358
19359 //finally... section data
19360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(!p_getc(&temp_use_cheats,f))
19361 {
19362 return qe_invalid;
19363 }
19364 443 }
19365
19366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 466 times.
466 if(Header->data_flags[ZQ_CHEATS2])
19367 {
19368
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 if(!p_igetl(&tempzcheats.flags,f))
19369 {
19370 return qe_invalid;
19371 }
19372
19373
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19374 {
19375 return qe_invalid;
19376 }
19377 466 }
19378
19379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 466 times.
466 if (should_skip)
19380 return 0;
19381
19382 466 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19383 466 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19384
19385 466 return 0;
19386 466 }
19387
19388 304 int32_t readinitdata_old(PACKFILE *f, zquestheader *Header, word s_version, zinitdata& temp_zinit)
19389 {
19390
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 281 times.
304 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
19391
19392 byte padding, tempbyte;
19393
19394 // Legacy item properties (now integrated into itemdata)
19395 byte sword_hearts[4];
19396 byte beam_hearts[4];
19397 304 byte beam_percent=0;
19398 word beam_power[4];
19399 304 byte hookshot_length=99;
19400 304 byte hookshot_links=100;
19401 304 byte longshot_length=99;
19402 304 byte longshot_links=100;
19403 304 byte moving_fairy_hearts=3;
19404 304 byte moving_fairy_heart_percent=0;
19405 304 byte stationary_fairy_hearts=3;
19406 304 byte stationary_fairy_heart_percent=0;
19407 304 byte moving_fairy_magic=0;
19408 304 byte moving_fairy_magic_percent=0;
19409 304 byte stationary_fairy_magic=0;
19410 304 byte stationary_fairy_magic_percent=0;
19411 304 byte blue_potion_hearts=100;
19412 304 byte blue_potion_heart_percent=1;
19413 304 byte red_potion_hearts=100;
19414 304 byte red_potion_heart_percent=1;
19415 304 byte blue_potion_magic=100;
19416 304 byte blue_potion_magic_percent=1;
19417 304 byte red_potion_magic=100;
19418 304 byte red_potion_magic_percent=1;
19419
19420 304 byte bomb_ratio = 4;
19421
19422 304 subscr_mode = 0;
19423
19424 /* HIGHLY UNORTHODOX UPDATING THING, by L
19425 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19426 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19427 * changing from 13 to 14.
19428 */
19429
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 82 times.
304 if(s_version < 14)
19430 82 fixpolsvoice=true;
19431
19432 /* End highly unorthodox updating thing */
19433
19434
4/4
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 114 times.
304 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19435 114 temp_zinit.jump_hero_layer_threshold=0;
19436
19437
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 222 times.
304 if(s_version >= 10)
19438 {
19439 char temp;
19440
19441 //new-style items
19442
2/2
✓ Branch 0 taken 56832 times.
✓ Branch 1 taken 222 times.
57054 for(int32_t j=0; j<256; j++)
19443 {
19444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56832 times.
56832 if(!p_getc(&temp,f))
19445 return qe_invalid;
19446
19447 56832 temp_zinit.set_item(j, temp != 0);
19448 56832 }
19449 222 }
19450
19451
5/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
304 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19452 {
19453 char temp;
19454
19455 //finally... section data
19456
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
291 if((Header->zelda_version > 0x192)||
19457 //new only
19458
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19459 {
19460 //OLD-style items... sigh
19461
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 60 times.
282 if(s_version < 10)
19462 {
19463
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19464 {
19465 return qe_invalid;
19466 }
19467
19468 60 temp_zinit.set_item(iRaft, temp != 0);
19469
19470
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19471 {
19472 return qe_invalid;
19473 }
19474
19475 60 temp_zinit.set_item(iLadder, temp != 0);
19476
19477
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19478 {
19479 return qe_invalid;
19480 }
19481
19482 60 temp_zinit.set_item(iBook, temp != 0);
19483
19484
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19485 {
19486 return qe_invalid;
19487 }
19488
19489 60 temp_zinit.set_item(iMKey, temp != 0);
19490
19491
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19492 {
19493 return qe_invalid;
19494 }
19495
19496 60 temp_zinit.set_item(iFlippers, temp != 0);
19497
19498
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19499 {
19500 return qe_invalid;
19501 }
19502
19503 60 temp_zinit.set_item(iBoots, temp != 0);
19504 60 }
19505 282 }
19506
19507
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
286 if(s_version < 10)
19508 {
19509 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19510
19511
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempring,f))
19512 {
19513 return qe_invalid;
19514 }
19515
19516
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempsword,f))
19517 {
19518 return qe_invalid;
19519 }
19520
19521
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempshield,f))
19522 {
19523 return qe_invalid;
19524 }
19525
19526
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwallet,f))
19527 {
19528 return qe_invalid;
19529 }
19530
19531
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbracelet,f))
19532 {
19533 return qe_invalid;
19534 }
19535
19536
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempamulet,f))
19537 {
19538 return qe_invalid;
19539 }
19540
19541
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbow,f))
19542 {
19543 return qe_invalid;
19544 }
19545
19546 //old only
19547
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
19548 {
19549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempring=(tempring)?(1<<(tempring-1)):0;
19550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19551
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19556 4 }
19557
19558 //rings start at level 2... wtf
19559 //account for this -DD
19560 64 tempring <<= 1;
19561 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19562 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19563 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19564 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19565 //bracelet ALSO starts at level 2 :-( -DD
19566 64 tempbracelet<<=1;
19567 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19568 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19569 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19570
19571 //new only
19572
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
64 if((Header->zelda_version == 0x192)&&(Header->build>173))
19573 {
19574
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
19575 {
19576
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
19577 {
19578 return qe_invalid;
19579 }
19580 32 }
19581 1 }
19582
19583 char tempcandle, tempboomerang, temparrow, tempwhistle;
19584
19585
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempcandle,f))
19586 {
19587 return qe_invalid;
19588 }
19589
19590
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempboomerang,f))
19591 {
19592 return qe_invalid;
19593 }
19594
19595
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temparrow,f))
19596 {
19597 return qe_invalid;
19598 }
19599
19600
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temp,f))
19601 {
19602 return qe_invalid;
19603 }
19604
19605 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19606
19607
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwhistle,f))
19608 {
19609 return qe_invalid;
19610 }
19611
19612 //old only
19613
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
19614 {
19615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19619 4 }
19620
19621 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19622 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19623 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19624 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19625 //What about the potion...?
19626
19627 64 }
19628
19629
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 269 times.
286 if(s_version < 29)
19630 {
19631 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19632 //to jab out my eye...
19633
1/2
✓ Branch 0 taken 269 times.
✗ Branch 1 not taken.
269 if(!p_getc(&padding,f))
19634 return qe_invalid;
19635 269 temp_zinit.counter[crBOMBS] = padding;
19636
19637
1/2
✓ Branch 0 taken 269 times.
✗ Branch 1 not taken.
269 if(!p_getc(&padding,f))
19638 return qe_invalid;
19639 269 temp_zinit.counter[crSBOMBS] = padding;
19640 269 }
19641
19642 //Back to more OLD item code
19643
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
286 if(s_version < 10)
19644 {
19645
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
69 if((Header->zelda_version > 0x192)||
19646 //new only
19647
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19648 {
19649
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19650 {
19651 return qe_invalid;
19652 }
19653
19654 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19655
19656
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19657 {
19658 return qe_invalid;
19659 }
19660
19661 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19662
19663
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19664 {
19665 return qe_invalid;
19666 }
19667
19668 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19669
19670
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19671 {
19672 return qe_invalid;
19673 }
19674
19675 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19676
19677
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19678 {
19679 return qe_invalid;
19680 }
19681
19682 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19683
19684
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19685 {
19686 return qe_invalid;
19687 }
19688
19689 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19690
19691
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19692 {
19693 return qe_invalid;
19694 }
19695
19696 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19697
19698
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19699 {
19700 return qe_invalid;
19701 }
19702
19703 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19704
19705
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19706 {
19707 return qe_invalid;
19708 }
19709
19710 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19711
19712
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19713 {
19714 return qe_invalid;
19715 }
19716
19717
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1 times.
60 if(Header->zelda_version == 0x192)
19718 {
19719
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
19720 {
19721
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
19722 {
19723 return qe_invalid;
19724 }
19725 32 }
19726 1 }
19727 60 }
19728 64 }
19729
19730 //old only
19731
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
286 if((Header->zelda_version == 0x192)&&(Header->build<174))
19732 {
19733 byte equipment, tmpitm; //bit flags
19734
19735
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&equipment,f))
19736 {
19737 return qe_invalid;
19738 }
19739
19740 4 temp_zinit.set_item(iRaft, get_bit(&equipment, idE_RAFT)!=0);
19741 4 temp_zinit.set_item(iLadder, get_bit(&equipment, idE_LADDER)!=0);
19742 4 temp_zinit.set_item(iBook, get_bit(&equipment, idE_BOOK)!=0);
19743 4 temp_zinit.set_item(iMKey, get_bit(&equipment, idE_KEY)!=0);
19744 4 temp_zinit.set_item(iFlippers, get_bit(&equipment, idE_FLIPPERS)!=0);
19745 4 temp_zinit.set_item(iBoots, get_bit(&equipment, idE_BOOTS)!=0);
19746
19747
19748
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tmpitm,f))
19749 {
19750 return qe_invalid;
19751 }
19752
19753 4 temp_zinit.set_item(iWand, get_bit(&tmpitm, idI_WAND)!=0);
19754 4 temp_zinit.set_item(iLetter, get_bit(&tmpitm, idI_LETTER)!=0);
19755 4 temp_zinit.set_item(iLens, get_bit(&tmpitm, idI_LENS)!=0);
19756 4 temp_zinit.set_item(iHookshot, get_bit(&tmpitm, idI_HOOKSHOT)!=0);
19757 4 temp_zinit.set_item(iBait, get_bit(&tmpitm, idI_BAIT)!=0);
19758 4 temp_zinit.set_item(iHammer, get_bit(&tmpitm, idI_HAMMER)!=0);
19759 4 }
19760
19761
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&tempbyte,f))
19762 return qe_invalid;
19763 286 temp_zinit.mcounter[crLIFE] = tempbyte;
19764
19765
19766
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version < 14)
19767 {
19768 byte temphp;
19769
19770
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
19771 {
19772 return qe_invalid;
19773 }
19774
19775 64 temp_zinit.counter[crLIFE]=temphp;
19776
19777
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
19778 {
19779 return qe_invalid;
19780 }
19781
19782 64 temp_zinit.cont_heart=temphp;
19783 64 }
19784 else
19785 {
19786
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.counter[crLIFE],f))
19787 {
19788 return qe_invalid;
19789 }
19790
19791
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.cont_heart,f))
19792 {
19793 return qe_invalid;
19794 }
19795 }
19796
19797
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&temp_zinit.hcp,f))
19798 {
19799 return qe_invalid;
19800 }
19801
19802
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version >= 14)
19803 {
19804
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&temp_zinit.hcp_per_hc,f))
19805 {
19806 return qe_invalid;
19807 }
19808
19809
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(s_version<16) // July 2007
19810 {
19811 if(get_qr(qr_BRANGPICKUP+1))
19812 temp_zinit.hcp_per_hc = 0xFF;
19813
19814 //Dispose of legacy rule
19815 set_qr(qr_BRANGPICKUP+1, 0);
19816 }
19817 222 }
19818
19819
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 269 times.
286 if(s_version < 29)
19820 {
19821
1/2
✓ Branch 0 taken 269 times.
✗ Branch 1 not taken.
269 if(!p_getc(&padding,f))
19822 return qe_invalid;
19823 269 temp_zinit.mcounter[crBOMBS] = padding;
19824 269 }
19825
19826
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&temp_zinit.counter[crKEYS],f))
19827 {
19828 return qe_invalid;
19829 }
19830
19831
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_igetw(&temp_zinit.counter[crMONEY],f))
19832 {
19833 return qe_invalid;
19834 }
19835
19836
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&tempbyte,f))
19837 return qe_invalid;
19838
2/2
✓ Branch 0 taken 2288 times.
✓ Branch 1 taken 286 times.
2574 for(int q = 0; q < 8; ++q)
19839 2288 set_bit(temp_zinit.mcguffin, q+1, get_bitl(tempbyte, q));
19840
19841
3/6
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
286 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19842 {
19843
2/2
✓ Branch 0 taken 14208 times.
✓ Branch 1 taken 222 times.
14430 for(int32_t i=0; i<64; i++)
19844 {
19845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14208 times.
14208 if(!p_getc(&temp_zinit.map[i],f))
19846 {
19847 return qe_invalid;
19848 }
19849 14208 }
19850
19851
2/2
✓ Branch 0 taken 14208 times.
✓ Branch 1 taken 222 times.
14430 for(int32_t i=0; i<64; i++)
19852 {
19853
1/2
✓ Branch 0 taken 14208 times.
✗ Branch 1 not taken.
14208 if(!p_getc(&temp_zinit.compass[i],f))
19854 {
19855 return qe_invalid;
19856 }
19857 14208 }
19858 222 }
19859 else
19860 {
19861
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 64 times.
2112 for(int32_t i=0; i<32; i++)
19862 {
19863
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 if(!p_getc(&temp_zinit.map[i],f))
19864 {
19865 return qe_invalid;
19866 }
19867 2048 }
19868
19869
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 64 times.
2112 for(int32_t i=0; i<32; i++)
19870 {
19871
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 if(!p_getc(&temp_zinit.compass[i],f))
19872 {
19873 return qe_invalid;
19874 }
19875 2048 }
19876 }
19877
19878
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
291 if((Header->zelda_version > 0x192)||
19879 //new only
19880
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19881 {
19882
3/6
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 222 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 60 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
282 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19883 {
19884
2/2
✓ Branch 0 taken 14208 times.
✓ Branch 1 taken 222 times.
14430 for(int32_t i=0; i<64; i++)
19885 {
19886
1/2
✓ Branch 0 taken 14208 times.
✗ Branch 1 not taken.
14208 if(!p_getc(&temp_zinit.boss_key[i],f))
19887 {
19888 return qe_invalid;
19889 }
19890 14208 }
19891 222 }
19892 else
19893 {
19894
2/2
✓ Branch 0 taken 1920 times.
✓ Branch 1 taken 60 times.
1980 for(int32_t i=0; i<32; i++)
19895 {
19896
1/2
✓ Branch 0 taken 1920 times.
✗ Branch 1 not taken.
1920 if(!p_getc(&temp_zinit.boss_key[i],f))
19897 {
19898 return qe_invalid;
19899 }
19900 1920 }
19901 }
19902 282 }
19903
19904 byte tmpmisc[16];
19905
2/2
✓ Branch 0 taken 4576 times.
✓ Branch 1 taken 286 times.
4862 for(int32_t i=0; i<16; i++)
19906
1/2
✓ Branch 0 taken 4576 times.
✗ Branch 1 not taken.
4576 if(!p_getc(&tmpmisc[i],f))
19907 return qe_invalid;
19908 286 temp_zinit.flags.set(INIT_FL_CONTPERCENT,get_bit(tmpmisc,0));
19909 286 temp_zinit.magicdrainrate = get_bit(tmpmisc,1) ? 1 : 2; //Double Magic flag
19910 286 temp_zinit.flags.set(INIT_FL_CANSLASH,get_bit(tmpmisc,2));
19911
19912
4/4
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 64 times.
542 if(s_version < 15) for(int32_t i=0; i<4; i++)
19913
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&sword_hearts[i],f))
19914 64 return qe_invalid;
19915
19916
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&temp_zinit.last_map,f))
19917 {
19918 return qe_invalid;
19919 }
19920
19921
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&temp_zinit.last_screen,f))
19922 {
19923 return qe_invalid;
19924 }
19925
19926
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version < 14)
19927 {
19928 byte tempmp;
19929
19930
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
19931 {
19932 return qe_invalid;
19933 }
19934
19935 64 temp_zinit.mcounter[crMAGIC]=tempmp;
19936
19937
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
19938 {
19939 return qe_invalid;
19940 }
19941
19942 64 temp_zinit.counter[crMAGIC]=tempmp;
19943 64 }
19944 else
19945 {
19946
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.mcounter[crMAGIC],f))
19947 {
19948 return qe_invalid;
19949 }
19950
19951
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.counter[crMAGIC],f))
19952 {
19953 return qe_invalid;
19954 }
19955 }
19956
19957
19958
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version < 15)
19959 {
19960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(s_version < 12)
19961 {
19962 64 temp_zinit.mcounter[crMAGIC]*=32;
19963 64 temp_zinit.counter[crMAGIC]*=32;
19964 64 }
19965
19966
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
19967 {
19968
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&beam_hearts[i],f))
19969 {
19970 return qe_invalid;
19971 }
19972 256 }
19973
19974
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&beam_percent,f))
19975 {
19976 return qe_invalid;
19977 }
19978 64 }
19979 else
19980 {
19981
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&temp_zinit.bomb_ratio,f))
19982 return qe_invalid;
19983
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(temp_zinit.bomb_ratio < 1)
19984 temp_zinit.bomb_ratio = 1;
19985 222 else bomb_ratio = temp_zinit.bomb_ratio; //jank
19986 }
19987
19988
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
286 if(s_version < 15)
19989 {
19990 byte tempbp;
19991
19992
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
19993 {
19994
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
256 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
19995 {
19996 return qe_invalid;
19997 }
19998
19999 256 beam_power[i]=tempbp;
20000 256 }
20001
20002
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&hookshot_links,f))
20003 {
20004 return qe_invalid;
20005 }
20006
20007
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(s_version>6)
20008 {
20009 if(!p_getc(&hookshot_length,f))
20010 {
20011 return qe_invalid;
20012 }
20013
20014 if(!p_getc(&longshot_links,f))
20015 {
20016 return qe_invalid;
20017 }
20018
20019 if(!p_getc(&longshot_length,f))
20020 {
20021 return qe_invalid;
20022 }
20023 }
20024 64 }
20025
20026
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&temp_zinit.msg_more_x,f))
20027 {
20028 return qe_invalid;
20029 }
20030
20031
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&temp_zinit.msg_more_y,f))
20032 {
20033 return qe_invalid;
20034 }
20035
20036
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&subscr_mode,f))
20037 return qe_invalid;
20038
20039 //old only
20040
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
286 if((Header->zelda_version == 0x192)&&(Header->build<174))
20041 {
20042
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 4 times.
132 for(int32_t i=0; i<32; i++)
20043 {
20044
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&temp_zinit.boss_key[i],f))
20045 {
20046 return qe_invalid;
20047 }
20048 128 }
20049 4 }
20050
20051
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 4 times.
286 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20052 {
20053
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 222 times.
282 if(s_version <= 10)
20054 {
20055
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&tempbyte,f))
20056 {
20057 return qe_invalid;
20058 }
20059
20060 60 temp_zinit.start_dmap = (word)tempbyte;
20061 60 }
20062 else
20063 {
20064
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.start_dmap,f))
20065 {
20066 return qe_invalid;
20067 }
20068 }
20069
20070
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20071 {
20072 return qe_invalid;
20073 }
20074 282 }
20075
20076
4/4
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 205 times.
286 if(s_version>1 && s_version < 29)
20077 {
20078
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_getc(&padding,f))
20079 return qe_invalid;
20080 205 temp_zinit.counter[crARROWS] = padding;
20081
20082
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_getc(&padding,f))
20083 return qe_invalid;
20084 205 temp_zinit.mcounter[crARROWS] = padding;
20085 205 }
20086
20087
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version>2)
20088 {
20089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222 times.
222 if(s_version <= 10)
20090 {
20091 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20092 {
20093 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20094 {
20095 return qe_invalid;
20096 }
20097 }
20098 }
20099 else
20100 {
20101
2/2
✓ Branch 0 taken 113664 times.
✓ Branch 1 taken 222 times.
113886 for(int32_t i=0; i<MAXLEVELS; i++)
20102 {
20103
1/2
✓ Branch 0 taken 113664 times.
✗ Branch 1 not taken.
113664 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20104 {
20105 return qe_invalid;
20106 }
20107 113664 }
20108 }
20109 222 }
20110
20111
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version>3)
20112 {
20113
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_grid_x,f))
20114 {
20115 return qe_invalid;
20116 }
20117
20118
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_grid_y,f))
20119 {
20120 return qe_invalid;
20121 }
20122
20123
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
20124 {
20125 return qe_invalid;
20126 }
20127
20128
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
20129 {
20130 return qe_invalid;
20131 }
20132
20133
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_grid_color,f))
20134 {
20135 return qe_invalid;
20136 }
20137
20138
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
20139 {
20140 return qe_invalid;
20141 }
20142
20143
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
20144 {
20145 return qe_invalid;
20146 }
20147
20148
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_flags,f))
20149 {
20150 return qe_invalid;
20151 }
20152
20153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222 times.
222 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222 times.
222 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20155 222 }
20156
20157
3/4
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 222 times.
✗ Branch 3 not taken.
286 if(s_version>4 && s_version<15)
20158 {
20159 if(!p_getc(&moving_fairy_hearts,f))
20160 {
20161 return qe_invalid;
20162 }
20163
20164 if(!p_getc(&moving_fairy_heart_percent,f))
20165 {
20166 return qe_invalid;
20167 }
20168 }
20169
20170
3/4
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 222 times.
✗ Branch 3 not taken.
286 if(s_version>5 && s_version < 10)
20171 {
20172 if(!p_getc(&temp,f))
20173 {
20174 return qe_invalid;
20175 }
20176
20177 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20178 }
20179
20180
3/4
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 222 times.
✗ Branch 3 not taken.
286 if(s_version>6 && s_version<15)
20181 {
20182 if(!p_getc(&stationary_fairy_hearts,f))
20183 {
20184 return qe_invalid;
20185 }
20186
20187 if(!p_getc(&stationary_fairy_heart_percent,f))
20188 {
20189 return qe_invalid;
20190 }
20191
20192 if(!p_getc(&moving_fairy_magic,f))
20193 {
20194 return qe_invalid;
20195 }
20196
20197 if(!p_getc(&moving_fairy_magic_percent,f))
20198 {
20199 return qe_invalid;
20200 }
20201
20202 if(!p_getc(&stationary_fairy_magic,f))
20203 {
20204 return qe_invalid;
20205 }
20206
20207 if(!p_getc(&stationary_fairy_magic_percent,f))
20208 {
20209 return qe_invalid;
20210 }
20211
20212 if(!p_getc(&blue_potion_hearts,f))
20213 {
20214 return qe_invalid;
20215 }
20216
20217 if(!p_getc(&blue_potion_heart_percent,f))
20218 {
20219 return qe_invalid;
20220 }
20221
20222 if(!p_getc(&red_potion_hearts,f))
20223 {
20224 return qe_invalid;
20225 }
20226
20227 if(!p_getc(&red_potion_heart_percent,f))
20228 {
20229 return qe_invalid;
20230 }
20231
20232 if(!p_getc(&blue_potion_magic,f))
20233 {
20234 return qe_invalid;
20235 }
20236
20237 if(!p_getc(&blue_potion_magic_percent,f))
20238 {
20239 return qe_invalid;
20240 }
20241
20242 if(!p_getc(&red_potion_magic,f))
20243 {
20244 return qe_invalid;
20245 }
20246
20247 if(!p_getc(&red_potion_magic_percent,f))
20248 {
20249 return qe_invalid;
20250 }
20251 }
20252
20253
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version>6)
20254
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&padding,f))
20255 return qe_invalid;
20256
20257
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version>7)
20258 {
20259
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&padding,f))
20260 {
20261 return qe_invalid;
20262 }
20263 222 }
20264
20265
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version>8)
20266 {
20267
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.mcounter[crMONEY],f))
20268 {
20269 return qe_invalid;
20270 }
20271
20272
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.mcounter[crKEYS],f))
20273 {
20274 return qe_invalid;
20275 }
20276 222 }
20277
20278
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
286 if(s_version>16)
20279 {
20280
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&tempbyte,f))
20281 {
20282 return qe_invalid;
20283 }
20284 222 temp_zinit.gravity = tempbyte*100;
20285
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.terminalv,f))
20286 {
20287 return qe_invalid;
20288 }
20289
20290
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&temp_zinit.msg_speed,f))
20291 {
20292 return qe_invalid;
20293 }
20294
20295
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&padding,f))
20296 {
20297 return qe_invalid;
20298 }
20299
20300
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20301 {
20302 return qe_invalid;
20303 }
20304 222 }
20305
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 12 times.
64 else if (replay_version_check(0, 13))
20306 12 temp_zinit.msg_speed = 0;
20307
20308
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version>17)
20309 {
20310
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20311 {
20312 return qe_invalid;
20313 }
20314 222 }
20315
20316 //expaned init data for larger values in 2.55
20317
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 17 times.
286 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20318 {
20319
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crBOMBS],f))
20320 {
20321 return qe_invalid;
20322 }
20323
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crSBOMBS],f))
20324 {
20325 return qe_invalid;
20326 }
20327
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crBOMBS],f))
20328 {
20329 return qe_invalid;
20330 }
20331
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crSBOMBS],f))
20332 {
20333 return qe_invalid;
20334 }
20335
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crARROWS],f))
20336 {
20337 return qe_invalid;
20338 }
20339
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crARROWS],f))
20340 {
20341 return qe_invalid;
20342 }
20343
20344 17 }
20345
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 269 times.
286 if ( s_version >= 20 )
20346 {
20347
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroStep,f))
20348 {
20349 return qe_invalid;
20350 }
20351 17 }
20352 else
20353 {
20354 269 temp_zinit.heroStep = 150; //1.5 pixels per frame
20355 }
20356
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 269 times.
286 if ( s_version >= 21 )
20357 {
20358
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20359 {
20360 return qe_invalid;
20361 }
20362 17 }
20363 else
20364 {
20365 269 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20366 }
20367 //old only
20368
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
286 if((Header->zelda_version == 0x192)&&(Header->build<174))
20369 {
20370 byte items2;
20371
20372
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&items2,f))
20373 {
20374 return qe_invalid;
20375 }
20376
20377 4 temp_zinit.set_item(iDivineFire, get_bit(&items2, idI_DFIRE)!=0);
20378 4 temp_zinit.set_item(iDivineEscape, get_bit(&items2, idI_FWIND)!=0);
20379 4 temp_zinit.set_item(iDivineProtection, get_bit(&items2, idI_NLOVE)!=0);
20380 4 }
20381
20382
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 5 times.
286 if(Header->zelda_version < 0x193)
20383 {
20384
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 5 times.
485 for(int32_t q=0; q<96; q++)
20385 {
20386
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(!p_getc(&padding,f))
20387 {
20388 return qe_invalid;
20389 }
20390 480 }
20391
20392 //new only
20393
3/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
5 if((Header->zelda_version == 0x192)&&(Header->build>173))
20394 {
20395
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20396 {
20397 return qe_invalid;
20398 }
20399
20400
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20401 {
20402 return qe_invalid;
20403 }
20404 1 }
20405 5 }
20406 286 }
20407
20408
3/6
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 222 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
304 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20409 {
20410 //temp_zinit.shield=i_smallshield;
20411 82 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20412
20413
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(sshieldid != -1)
20414 82 temp_zinit.set_item(sshieldid, true);
20415 82 }
20416
20417
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20418 {
20419 18 temp_zinit.mcounter[crLIFE]=3;
20420 18 temp_zinit.counter[crLIFE]=3;
20421 18 temp_zinit.cont_heart=3;
20422 18 temp_zinit.mcounter[crBOMBS]=8;
20423 18 }
20424
20425
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20426 {
20427 18 sword_hearts[0]=0;
20428 18 sword_hearts[1]=5;
20429 18 sword_hearts[2]=12;
20430 18 sword_hearts[3]=21;
20431 18 }
20432
20433
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20434 {
20435 18 temp_zinit.last_map=0;
20436 18 temp_zinit.last_screen=0;
20437 18 }
20438
20439
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20440 {
20441 18 temp_zinit.mcounter[crMAGIC]=0;
20442 18 temp_zinit.counter[crMAGIC]=0;
20443 18 temp_zinit.magicdrainrate = 2;
20444 18 }
20445
20446
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20447 {
20448
20449
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20450 {
20451 72 beam_hearts[x]=100;
20452 72 }
20453
20454
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t i=0; i<idBP_MAX; i++)
20455 {
20456 72 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20457 72 set_qr(qr_LENSHINTS+i,0);
20458 72 }
20459
20460
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20461 {
20462 72 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20463 72 }
20464
20465 18 set_qr(qr_HIDECARRIEDITEMS,0);
20466 18 hookshot_links=100;
20467 18 temp_zinit.msg_more_x=224;
20468 18 temp_zinit.msg_more_y=64;
20469 18 }
20470
20471 // Okay, let's put these legacy values into itemsbuf.
20472
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 82 times.
304 if(s_version < 15)
20473
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
20474 {
20475
11/11
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 20172 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
20992 switch(i)
20476 {
20477 case iFairyStill:
20478 82 itemsbuf[i].misc1 = stationary_fairy_hearts;
20479 82 itemsbuf[i].misc2 = stationary_fairy_magic;
20480 82 itemsbuf[i].misc3 = 0;
20481
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
20482
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
20483 82 break;
20484
20485 case iFairyMoving:
20486 82 itemsbuf[i].misc1 = moving_fairy_hearts;
20487 82 itemsbuf[i].misc2 = moving_fairy_magic;
20488 82 itemsbuf[i].misc3 = 50;
20489
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
20490
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
20491 82 break;
20492
20493 case iRPotion:
20494 82 itemsbuf[i].misc1 = red_potion_hearts;
20495 82 itemsbuf[i].misc2 = red_potion_magic;
20496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
20497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
20498 82 break;
20499
20500 case iBPotion:
20501 82 itemsbuf[i].misc1 = blue_potion_hearts;
20502 82 itemsbuf[i].misc2 = blue_potion_magic;
20503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
20504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
20505 82 break;
20506
20507 case iSword:
20508 82 itemsbuf[i].pickup_hearts = sword_hearts[0];
20509 82 itemsbuf[i].misc1 = beam_hearts[0];
20510 82 itemsbuf[i].misc2 = beam_power[0];
20511 // It seems that item_flag1 was already added by reset_itembuf()...
20512 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~item_flag1 : ~item_none;
20513 82 break;
20514
20515 case iWSword:
20516 82 itemsbuf[i].pickup_hearts = sword_hearts[1];
20517 82 itemsbuf[i].misc1 = beam_hearts[1];
20518 82 itemsbuf[i].misc2 = beam_power[1];
20519 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~item_flag1 : ~item_none;
20520 82 break;
20521
20522 case iMSword:
20523 82 itemsbuf[i].pickup_hearts = sword_hearts[2];
20524 82 itemsbuf[i].misc1 = beam_hearts[2];
20525 82 itemsbuf[i].misc2 = beam_power[2];
20526 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~item_flag1 : ~item_none;
20527 82 break;
20528
20529 case iXSword:
20530 82 itemsbuf[i].pickup_hearts = sword_hearts[3];
20531 82 itemsbuf[i].misc1 = beam_hearts[3];
20532 82 itemsbuf[i].misc2 = beam_power[3];
20533 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~item_flag1 : ~item_none;
20534 82 break;
20535
20536 case iHookshot:
20537 82 itemsbuf[i].misc1 = hookshot_length;
20538 82 itemsbuf[i].misc2 = hookshot_links;
20539 82 break;
20540
20541 case iLongshot:
20542 82 itemsbuf[i].misc1 = longshot_length;
20543 82 itemsbuf[i].misc2 = longshot_links;
20544 82 break;
20545 }
20546 21074 }
20547
20548
6/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20549 {
20550 //was new subscreen rule
20551 22 subscr_mode=get_qr(qr_FREEFORM)?1:0;
20552 22 set_qr(qr_FREEFORM,0);
20553 22 }
20554
20555
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20556 {
20557 23 temp_zinit.start_dmap=0;
20558 23 }
20559
20560
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20561 {
20562 23 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
20563 23 }
20564
20565
3/4
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 222 times.
✓ Branch 2 taken 82 times.
✗ Branch 3 not taken.
304 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20566 {
20567 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20568 temp_zinit.mcounter[crMONEY]=999;
20569 //temp_zinit.counter[crMONEY]=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20570 }
20571
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 6 times.
304 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20572 {
20573 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20574 6 temp_zinit.mcounter[crBOMBS] = 8;
20575 6 }
20576 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20577 //time to ensure that we port all new values properly:
20578
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 82 times.
304 if(Header->zelda_version < 0x250)
20579 {
20580
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 temp_zinit.mcounter[crSBOMBS] = bomb_ratio > 0 ? ( temp_zinit.mcounter[crBOMBS]/temp_zinit.bomb_ratio ) : (temp_zinit.mcounter[crBOMBS]/4);
20581 82 }
20582
20583
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 21)
20584 {
20585
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.hp_per_heart,f))
20586 {
20587 return qe_invalid;
20588 }
20589
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.magic_per_block,f))
20590 {
20591 return qe_invalid;
20592 }
20593
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20594 {
20595 return qe_invalid;
20596 }
20597
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20598 {
20599 return qe_invalid;
20600 }
20601 17 }
20602 else
20603 {
20604 287 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20605 287 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20606 287 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20607 287 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20608 }
20609
20610
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 17 times.
304 if(s_version > 22)
20611 {
20612
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 17 times.
442 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if(!p_igetw(&temp_zinit.counter[q],f))
20614 return qe_invalid;
20615
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 17 times.
442 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if(!p_igetw(&temp_zinit.mcounter[q],f))
20617 return qe_invalid;
20618 17 }
20619
20620
20621
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 23)
20622 {
20623
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_type,f))
20624 {
20625 return qe_invalid;
20626 }
20627
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_arg,f))
20628 {
20629 return qe_invalid;
20630 }
20631
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_percent,f))
20632 {
20633 return qe_invalid;
20634 }
20635
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.def_lightrad,f))
20636 {
20637 return qe_invalid;
20638 }
20639
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.transdark_percent,f))
20640 {
20641 return qe_invalid;
20642 }
20643 17 }
20644 else
20645 {
20646 287 temp_zinit.dither_type = 0;
20647 287 temp_zinit.dither_arg = 0;
20648 287 temp_zinit.dither_percent = 20;
20649 287 temp_zinit.def_lightrad = 24;
20650 287 temp_zinit.transdark_percent = 0;
20651 }
20652
20653
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 24)
20654 {
20655
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.darkcol,f))
20656 {
20657 return qe_invalid;
20658 }
20659 17 }
20660 else
20661 {
20662 287 temp_zinit.darkcol = BLACK;
20663 }
20664
20665
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 17 times.
304 if(s_version > 25)
20666 {
20667
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.gravity,f))
20668 {
20669 return qe_invalid;
20670 }
20671
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.swimgravity,f))
20672 {
20673 return qe_invalid;
20674 }
20675 17 }
20676
20677
20678
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 26)
20679 {
20680
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20681 {
20682 return qe_invalid;
20683 }
20684
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20685 {
20686 return qe_invalid;
20687 }
20688
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20689 {
20690 return qe_invalid;
20691 }
20692 17 }
20693 else
20694 {
20695 287 temp_zinit.heroSideswimUpStep = 150;
20696 287 temp_zinit.heroSideswimSideStep = 100;
20697 287 temp_zinit.heroSideswimDownStep = 75;
20698 }
20699
20700
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 27)
20701 {
20702
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20703 {
20704 return qe_invalid;
20705 }
20706 17 }
20707 else
20708 {
20709 287 temp_zinit.exitWaterJump = 0;
20710 }
20711
20712
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 29)
20713 {
20714
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20715 {
20716 return qe_invalid;
20717 }
20718 17 }
20719 else
20720 {
20721 287 temp_zinit.bunny_ltm = 0;
20722 }
20723
20724
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 30)
20725 {
20726
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.switchhookstyle,f))
20727 {
20728 return qe_invalid;
20729 }
20730 17 }
20731 else
20732 {
20733 287 temp_zinit.switchhookstyle = 1;
20734 }
20735
20736
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 17 times.
304 if(s_version > 31)
20737 {
20738
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.magicdrainrate,f))
20739 {
20740 return qe_invalid;
20741 }
20742 17 }
20743
20744 304 temp_zinit.clear_genscript();
20745
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 12 times.
304 if(s_version > 32)
20746 {
20747 12 word numgenscript = 0;
20748
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&numgenscript,f))
20749 return qe_invalid;
20750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (numgenscript > NUMSCRIPTSGENERIC)
20751 return qe_invalid;
20752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 for(auto q = 1; q < numgenscript; ++q)
20753 {
20754 if(!p_getc(&tempbyte,f))
20755 return qe_invalid;
20756 if(!(tempbyte&2))
20757 continue;
20758 temp_zinit.gen_doscript.set(q, tempbyte&1);
20759 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
20760 return qe_invalid;
20761 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
20762 return qe_invalid;
20763 for(auto p = 0; p < 8; ++p)
20764 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
20765 return qe_invalid;
20766 dword sz;
20767 if(!p_igetl(&sz,f))
20768 return qe_invalid;
20769 temp_zinit.gen_data[q].resize(sz);
20770 std::vector<int32_t> dummy;
20771 if(!p_getlvec(&dummy,f))
20772 return qe_invalid;
20773 temp_zinit.gen_data[q] = dummy;
20774 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
20775 return qe_invalid;
20776 }
20777 12 }
20778
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 6 times.
304 if(s_version > 33)
20779 {
20780
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20781 return qe_invalid;
20782
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&temp_zinit.hero_swim_div,f))
20783 return qe_invalid;
20784 6 }
20785
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(s_version > 34)
20786 {
20787 uint32_t num_used_mapscr_data;
20788 if(!p_igetl(&num_used_mapscr_data,f))
20789 return qe_invalid;
20790 for(uint32_t q = 0; q < num_used_mapscr_data; ++q)
20791 {
20792 uint32_t sz;
20793 if(!p_igetl(&sz,f))
20794 return qe_invalid;
20795 temp_zinit.screen_data[q].resize(sz);
20796 if(sz)
20797 {
20798 std::vector<int32_t> dummy;
20799 if(!p_getlvec(&dummy,f))
20800 return qe_invalid;
20801 temp_zinit.screen_data[q] = dummy;
20802 }
20803 }
20804 }
20805
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if (s_version > 35)
20806 if(!p_igetzf(&temp_zinit.shove_offset,f))
20807 return qe_invalid;
20808
20809 304 temp_zinit.counter[crLIFE] *= temp_zinit.hp_per_heart;
20810 304 temp_zinit.mcounter[crLIFE] *= temp_zinit.hp_per_heart;
20811
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 110 times.
304 if(!temp_zinit.flags.get(INIT_FL_CONTPERCENT))
20812 110 temp_zinit.cont_heart *= temp_zinit.hp_per_heart;
20813
20814 304 return 0;
20815 304 }
20816 466 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
20817 {
20818 466 zinitdata temp_zinit = {};
20819
20820
3/4
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
466 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
20821
20822 int32_t dummy;
20823 466 word s_version=0;
20824 byte padding;
20825
20826
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 23 times.
466 if(Header->zelda_version > 0x192)
20827 {
20828
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetw(&s_version,f))
20829 return qe_invalid;
20830 443 FFCore.quest_format[vInitData] = s_version;
20831
20832
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!read_deprecated_section_cversion(f))
20833 return qe_invalid;
20834
20835 //section size
20836
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetl(&dummy,f))
20837 return qe_invalid;
20838 443 }
20839
20840
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 162 times.
466 if(s_version < 37)
20841 {
20842
2/4
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 304 times.
304 if(auto ret = readinitdata_old(f,Header,s_version,temp_zinit))
20843 return ret;
20844 304 }
20845 else
20846 {
20847 162 subscr_mode = ssdtMAX;
20848
2/2
✓ Branch 0 taken 5184 times.
✓ Branch 1 taken 162 times.
5346 for(int q = 0; q < MAXITEMS/8; ++q)
20849
2/4
✓ Branch 0 taken 5184 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5184 times.
5184 if(!p_getc(&temp_zinit.items[q], f))
20850 return qe_invalid;
20851
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 10368 times.
10530 for(int q = 0; q < MAXLEVELS/8; ++q)
20852 {
20853
2/4
✓ Branch 0 taken 10368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10368 times.
✗ Branch 3 not taken.
10368 if(!p_getc(&temp_zinit.map[q], f))
20854 return qe_invalid;
20855
2/4
✓ Branch 0 taken 10368 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10368 times.
10368 if(!p_getc(&temp_zinit.compass[q], f))
20856 return qe_invalid;
20857
2/4
✓ Branch 0 taken 10368 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10368 times.
10368 if(!p_getc(&temp_zinit.boss_key[q], f))
20858 return qe_invalid;
20859
2/4
✓ Branch 0 taken 10368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10368 times.
✗ Branch 3 not taken.
10368 if(!p_getc(&temp_zinit.mcguffin[q], f))
20860 return qe_invalid;
20861 10368 }
20862
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getbvec(&temp_zinit.level_keys, f))
20863 return qe_invalid;
20864 byte num_counters;
20865
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&num_counters,f))
20866 return qe_invalid;
20867
2/2
✓ Branch 0 taken 17334 times.
✓ Branch 1 taken 162 times.
17496 for(int q = 0; q < num_counters; ++q)
20868
2/4
✓ Branch 0 taken 17334 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17334 times.
17334 if(!p_igetw(&temp_zinit.counter[q],f))
20869 return qe_invalid;
20870
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 17334 times.
17496 for(int q = 0; q < num_counters; ++q)
20871
2/4
✓ Branch 0 taken 17334 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17334 times.
17334 if(!p_igetw(&temp_zinit.mcounter[q],f))
20872 return qe_invalid;
20873
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.bomb_ratio,f))
20874 return qe_invalid;
20875
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.hcp,f))
20876 return qe_invalid;
20877
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.hcp_per_hc,f))
20878 return qe_invalid;
20879
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_igetw(&temp_zinit.cont_heart,f))
20880 return qe_invalid;
20881
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.hp_per_heart,f))
20882 return qe_invalid;
20883
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.magic_per_block,f))
20884 return qe_invalid;
20885
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20886 return qe_invalid;
20887
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20888 return qe_invalid;
20889
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.dither_type,f))
20890 return qe_invalid;
20891
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.dither_arg,f))
20892 return qe_invalid;
20893
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.dither_percent,f))
20894 return qe_invalid;
20895
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.def_lightrad,f))
20896 return qe_invalid;
20897
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.transdark_percent,f))
20898 return qe_invalid;
20899
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.darkcol,f))
20900 return qe_invalid;
20901
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_igetl(&temp_zinit.ss_grid_x,f))
20902 return qe_invalid;
20903
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_igetl(&temp_zinit.ss_grid_y,f))
20904 return qe_invalid;
20905
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_igetl(&temp_zinit.ss_grid_xofs,f))
20906 return qe_invalid;
20907
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_igetl(&temp_zinit.ss_grid_yofs,f))
20908 return qe_invalid;
20909
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_igetl(&temp_zinit.ss_grid_color,f))
20910 return qe_invalid;
20911
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_igetl(&temp_zinit.ss_bbox_1_color,f))
20912 return qe_invalid;
20913
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_igetl(&temp_zinit.ss_bbox_2_color,f))
20914 return qe_invalid;
20915
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_igetl(&temp_zinit.ss_flags,f))
20916 return qe_invalid;
20917
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getbitstr(&temp_zinit.flags,f))
20918 return qe_invalid;
20919
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.last_map,f))
20920 return qe_invalid;
20921
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.last_screen,f))
20922 return qe_invalid;
20923
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.msg_more_x,f))
20924 return qe_invalid;
20925
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.msg_more_y,f))
20926 return qe_invalid;
20927
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20928 return qe_invalid;
20929
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.msg_speed,f))
20930 return qe_invalid;
20931
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_igetl(&temp_zinit.gravity,f))
20932 return qe_invalid;
20933
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_igetl(&temp_zinit.swimgravity,f))
20934 return qe_invalid;
20935
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_igetw(&temp_zinit.terminalv,f))
20936 return qe_invalid;
20937
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.hero_swim_speed,f))
20938 return qe_invalid;
20939
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20940 return qe_invalid;
20941
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.hero_swim_div,f))
20942 return qe_invalid;
20943
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20944 return qe_invalid;
20945
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20946 return qe_invalid;
20947
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20948 return qe_invalid;
20949
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20950 return qe_invalid;
20951
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_igetw(&temp_zinit.heroStep,f))
20952 return qe_invalid;
20953
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20954 return qe_invalid;
20955
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20956 return qe_invalid;
20957
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20958 return qe_invalid;
20959
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_igetw(&temp_zinit.start_dmap,f))
20960 return qe_invalid;
20961
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20962 return qe_invalid;
20963
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.switchhookstyle,f))
20964 return qe_invalid;
20965
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getc(&temp_zinit.magicdrainrate,f))
20966 return qe_invalid;
20967
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_igetzf(&temp_zinit.shove_offset,f))
20968 return qe_invalid;
20969
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getbitstr(&temp_zinit.gen_doscript, f))
20970 return qe_invalid;
20971
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getbmap(&temp_zinit.gen_exitState, f))
20972 return qe_invalid;
20973
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getbmap(&temp_zinit.gen_reloadState, f))
20974 return qe_invalid;
20975
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getbmap(&temp_zinit.gen_initd, f))
20976 return qe_invalid;
20977
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getbmap(&temp_zinit.gen_eventstate, f))
20978 return qe_invalid;
20979
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getbmap(&temp_zinit.gen_data, f))
20980 return qe_invalid;
20981
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if(!p_getbmap(&temp_zinit.screen_data, f))
20982 return qe_invalid;
20983
1/2
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
162 if (s_version >= 38)
20984 {
20985
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if (!p_getc(&temp_zinit.spriteflickerspeed, f))
20986 return qe_invalid;
20987
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if (!p_getc(&temp_zinit.spriteflickercolor, f))
20988 return qe_invalid;
20989
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
162 if (!p_getc(&temp_zinit.spriteflickertransp, f))
20990 return qe_invalid;
20991 162 }
20992
2/2
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 28 times.
162 if(s_version >= 39)
20993
2/4
✓ Branch 0 taken 134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 134 times.
✗ Branch 3 not taken.
134 if(!p_igetzf(&temp_zinit.air_drag, f))
20994 return qe_invalid;
20995
20996 // TODO: this first branch can likely be removed, as it only fixes an issues
20997 // that existed for a handful of temporary z3 builds (and active users of that
20998 // fork would have been updating often, beyond s_version 40).
20999
3/4
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 134 times.
162 if (Header->is_z3 && s_version == 40)
21000 {
21001 if(!p_getc(&temp_zinit.region_mapping, f))
21002 return qe_invalid;
21003 }
21004 else
21005 {
21006
2/2
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 28 times.
162 if(s_version >= 40)
21007 {
21008
2/4
✓ Branch 0 taken 134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 134 times.
✗ Branch 3 not taken.
134 if(!p_igetw(&temp_zinit.light_wave_rate, f))
21009 return qe_invalid;
21010
2/4
✓ Branch 0 taken 134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 134 times.
✗ Branch 3 not taken.
134 if(!p_igetw(&temp_zinit.light_wave_size, f))
21011 return qe_invalid;
21012 134 }
21013
21014
2/2
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 28 times.
162 if(s_version >= 41)
21015 {
21016
2/4
✓ Branch 0 taken 134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 134 times.
✗ Branch 3 not taken.
134 if(!p_getc(&temp_zinit.region_mapping, f))
21017 return qe_invalid;
21018 134 }
21019 }
21020 }
21021
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 if (should_skip)
21022 return 0;
21023
21024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 466 times.
466 if(loading_tileset_flags & TILESET_CLEARMAPS)
21025 {
21026 temp_zinit.last_map = 0;
21027 temp_zinit.last_screen = 0;
21028 temp_zinit.screen_data.clear();
21029 }
21030
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 temp_zinit.normalize();
21031
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 zinit = temp_zinit;
21032
21033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 466 times.
466 if(zinit.heroAnimationStyle==las_zelda3slow)
21034 {
21035 hero_animation_speed=2;
21036 }
21037 else
21038 {
21039 466 hero_animation_speed=1;
21040 }
21041
21042 466 return 0;
21043 466 }
21044
21045 /*
21046 void setupitemdropsets()
21047 {
21048 for(int32_t i=0; i<isMAX; i++)
21049 {
21050 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21051 }
21052 }
21053 */
21054
21055 407 int32_t readitemdropsets(PACKFILE *f, int32_t version)
21056 {
21057
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 23 times.
407 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_itemdropsets);
21058
21059 dword dummy_dword;
21060 407 word item_drop_sets_to_read=0;
21061 item_drop_object tempitemdrop;
21062 407 word s_version=0;
21063
21064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 407 times.
407 if (!should_skip)
21065
2/2
✓ Branch 0 taken 104192 times.
✓ Branch 1 taken 407 times.
104599 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21066 {
21067 104192 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21068 104599 }
21069
21070
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 23 times.
407 if(version > 0x192)
21071 {
21072 384 item_drop_sets_to_read=0;
21073
21074 //section version info
21075
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetw(&s_version,f))
21076 {
21077 return qe_invalid;
21078 }
21079
21080 384 FFCore.quest_format[vItemDropsets] = s_version;
21081
21082
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!read_deprecated_section_cversion(f))
21083 {
21084 return qe_invalid;
21085 }
21086
21087 //section size
21088
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetl(&dummy_dword,f))
21089 {
21090 return qe_invalid;
21091 }
21092
21093 //finally... section data
21094
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetw(&item_drop_sets_to_read,f))
21095 {
21096 return qe_invalid;
21097 }
21098
21099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if (item_drop_sets_to_read > MAXITEMDROPSETS)
21100 {
21101 return qe_invalid;
21102 }
21103 384 }
21104 else
21105 {
21106 23 init_item_drop_sets();
21107 }
21108
21109
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 384 times.
407 if(s_version>=1)
21110 {
21111
2/2
✓ Branch 0 taken 5834 times.
✓ Branch 1 taken 384 times.
6218 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21112 {
21113
1/2
✓ Branch 0 taken 5834 times.
✗ Branch 1 not taken.
5834 if(!p_getstr(tempitemdrop.name,sizeof(tempitemdrop.name)-1,f))
21114 {
21115 return qe_invalid;
21116 }
21117
21118
2/2
✓ Branch 0 taken 58340 times.
✓ Branch 1 taken 5834 times.
64174 for(int32_t j=0; j<10; ++j)
21119 {
21120
1/2
✓ Branch 0 taken 58340 times.
✗ Branch 1 not taken.
58340 if(!p_igetw(&tempitemdrop.item[j],f))
21121 {
21122 return qe_invalid;
21123 }
21124 58340 }
21125
21126
2/2
✓ Branch 0 taken 64174 times.
✓ Branch 1 taken 5834 times.
70008 for(int32_t j=0; j<11; ++j)
21127 {
21128
1/2
✓ Branch 0 taken 64174 times.
✗ Branch 1 not taken.
64174 if(!p_igetw(&tempitemdrop.chance[j],f))
21129 {
21130 return qe_invalid;
21131 }
21132 64174 }
21133
21134 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21135 // overrides the quest's set #12.
21136
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5834 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5834 if(s_version<2 && i==12)
21137 continue;
21138
21139 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21140
1/4
✓ Branch 0 taken 5834 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5834 if(s_version<2) for(int32_t j=0; j<10; ++j)
21141 {
21142 int32_t it = tempitemdrop.item[j];
21143
21144 if((itemsbuf[it].family == itype_rupee
21145 && ((itemsbuf[it].amount)&0xFFF) == 10)
21146 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21147 {
21148 tempitemdrop.chance[j+1]=0;
21149 }
21150 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21151 {
21152 tempitemdrop.chance[j+1]=0;
21153 }
21154
21155 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21156 if(itemsbuf[it].family == itype_misc)
21157 {
21158 // If a non-gameplay item was selected, then item drop was aborted.
21159 // Reflect this by increasing the 'Nothing' chance accordingly.
21160 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21161 tempitemdrop.chance[j+1]=0;
21162 }
21163 }
21164
21165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5834 times.
5834 if (!should_skip)
21166 5834 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21167 5834 }
21168 384 }
21169
21170 407 return 0;
21171 407 }
21172
21173 384 int32_t readfavorites(PACKFILE *f, int32_t)
21174 {
21175
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_favorites);
21176
21177 int32_t temp_num;
21178 dword dummy_dword;
21179 word num_favorite_combos;
21180 word num_favorite_combo_aliases;
21181 384 word s_version=0;
21182
21183 //section version info
21184
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetw(&s_version,f))
21185 {
21186 return qe_invalid;
21187 }
21188
21189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if (!should_skip)
21190 384 FFCore.quest_format[vFavourites] = s_version;
21191
21192
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!read_deprecated_section_cversion(f))
21193 {
21194 return qe_invalid;
21195 }
21196
21197 //section size
21198
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetl(&dummy_dword,f))
21199 {
21200 return qe_invalid;
21201 }
21202
21203 384 word per_row = FAVORITECOMBO_PER_ROW;
21204 384 word per_page = FAVORITECOMBO_PER_PAGE;
21205
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 168 times.
384 if(s_version >= 3)
21206
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(!p_igetw(&per_row,f))
21207 return qe_invalid;
21208
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 162 times.
384 if(s_version >= 4)
21209
1/2
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
162 if(!p_igetw(&per_page,f))
21210 return qe_invalid;
21211 //finally... section data
21212
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetw(&num_favorite_combos,f))
21213 {
21214 return qe_invalid;
21215 }
21216
21217 //Hack; port old favorite combos
21218
3/4
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 168 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 216 times.
384 if(s_version < 3 && num_favorite_combos == 100)
21219 216 per_row = 13;
21220
21221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if (!should_skip)
21222
2/2
✓ Branch 0 taken 483840 times.
✓ Branch 1 taken 384 times.
484224 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21223 484224 favorite_combos[q] = -1;
21224 384 byte favtype = 0;
21225
2/2
✓ Branch 0 taken 28027 times.
✓ Branch 1 taken 384 times.
28411 for(int32_t i=0; i<num_favorite_combos; i++)
21226 {
21227
2/2
✓ Branch 0 taken 6421 times.
✓ Branch 1 taken 21606 times.
28027 if (s_version >= 4)
21228 {
21229
1/2
✓ Branch 0 taken 6421 times.
✗ Branch 1 not taken.
6421 if (!p_getc(&favtype, f))
21230 {
21231 return qe_invalid;
21232 }
21233 6421 }
21234 else
21235 21606 favtype = 0;
21236
1/2
✓ Branch 0 taken 28027 times.
✗ Branch 1 not taken.
28027 if(!p_igetl(&temp_num,f))
21237 {
21238 return qe_invalid;
21239 }
21240
21241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28027 times.
28027 if (should_skip)
21242 continue;
21243
21244
2/2
✓ Branch 0 taken 6421 times.
✓ Branch 1 taken 21606 times.
28027 if(per_row == FAVORITECOMBO_PER_ROW)
21245 {
21246 6421 favorite_combos[i] = temp_num;
21247 6421 favorite_combo_modes[i] = favtype;
21248 6421 }
21249 else
21250 {
21251 21606 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21252 21606 favorite_combos[new_i]=temp_num;
21253 21606 favorite_combo_modes[new_i] = favtype;
21254 }
21255 28027 }
21256
21257 // Discard the separate favorite aliases list from previous versions
21258
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 222 times.
384 if(s_version<4)
21259 {
21260
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if (!p_igetw(&num_favorite_combo_aliases, f))
21261 {
21262 return qe_invalid;
21263 }
21264
21265
2/2
✓ Branch 0 taken 21600 times.
✓ Branch 1 taken 222 times.
21822 for (int32_t i = 0; i < num_favorite_combo_aliases; i++)
21266 {
21267
1/2
✓ Branch 0 taken 21600 times.
✗ Branch 1 not taken.
21600 if (!p_igetl(&temp_num, f))
21268 {
21269 return qe_invalid;
21270 }
21271 21600 }
21272 222 }
21273
21274 384 word max_combo_cols = 0;
21275 384 word max_mappages = 0;
21276
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 168 times.
384 if(s_version >= 2)
21277 {
21278
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(!p_igetw(&max_combo_cols,f))
21279 return qe_invalid;
21280 168 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21281
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 168 times.
840 for(int q = 0; q < max_combo_cols; ++q)
21282 {
21283
1/2
✓ Branch 0 taken 672 times.
✗ Branch 1 not taken.
672 if(!p_igetl(&tmp,f))
21284 return qe_invalid;
21285
1/2
✓ Branch 0 taken 672 times.
✗ Branch 1 not taken.
672 if(!p_igetl(&tmp2,f))
21286 return qe_invalid;
21287
1/2
✓ Branch 0 taken 672 times.
✗ Branch 1 not taken.
672 if(!p_igetl(&tmp3,f))
21288 return qe_invalid;
21289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 672 times.
672 if(q < MAX_COMBO_COLS)
21290 {
21291 672 First[q] = tmp;
21292 672 combo_alistpos[q] = tmp2;
21293 672 combo_pool_listpos[q] = tmp3;
21294 672 }
21295 672 }
21296
21297
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(!p_igetw(&max_mappages,f))
21298 return qe_invalid;
21299
2/2
✓ Branch 0 taken 1512 times.
✓ Branch 1 taken 168 times.
1680 for(int q = 0; q < max_mappages; ++q)
21300 {
21301
1/2
✓ Branch 0 taken 1512 times.
✗ Branch 1 not taken.
1512 if(!p_igetl(&tmp,f))
21302 return qe_invalid;
21303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1512 times.
1512 if(!p_igetl(&tmp2,f))
21304 return qe_invalid;
21305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1512 times.
1512 if(q < MAX_MAPPAGE_BTNS)
21306 {
21307 1512 map_page[q].map = tmp;
21308 1512 map_page[q].screen = tmp2;
21309 1512 }
21310 1512 }
21311 168 }
21312
21313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if (should_skip)
21314 return 0;
21315
21316
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 384 times.
1248 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21317 {
21318 864 First[q] = 0;
21319 864 combo_alistpos[q] = 0;
21320 864 combo_pool_listpos[q] = 0;
21321 864 }
21322
2/2
✓ Branch 0 taken 1944 times.
✓ Branch 1 taken 384 times.
2328 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21323 {
21324 1944 map_page[q].map = 0;
21325 1944 map_page[q].screen = 0;
21326 1944 }
21327
21328 384 return 0;
21329 384 }
21330
21331 /*
21332 switch (ret) {
21333 case 0:
21334 break;
21335
21336 case qe_invalid:
21337 goto invalid;
21338 break;
21339 default:
21340 pack_fclose(f);
21341 if(!oldquest)
21342 delete_file(tmpfilename);
21343 return ret;
21344 break;
21345 }
21346 */
21347
21348 const char *skip_text[skip_max]=
21349 {
21350 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21351 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21352 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21353 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21354 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21355 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21356 "skip_favorites"
21357 };
21358
21359
21360 void port250QuestRules(){
21361
21362 portCandleRules(); //Candle
21363 portBombRules();
21364
21365 }
21366
21367 void portCandleRules()
21368 {
21369 bool hurtshero = get_qr(qr_FIREPROOFHERO);
21370 //itemdata itemsbuf;
21371 for ( int32_t q = 0; q < MAXITEMS; q++ )
21372 {
21373 if ( itemsbuf[q].family == itype_candle )
21374 {
21375 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
21376 else itemsbuf[q].flags &= ~ item_flag2;
21377 }
21378 }
21379 }
21380
21381 void portBombRules()
21382 {
21383 bool hurtshero = get_qr(qr_OUCHBOMBS);
21384 //itemdata itemsbuf;
21385 for ( int32_t q = 0; q < MAXITEMS; q++ )
21386 {
21387 if ( itemsbuf[q].family == itype_bomb )
21388 {
21389 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
21390 else itemsbuf[q].flags &= ~ item_flag2;
21391 }
21392 }
21393 }
21394
21395 18045 static int section_id_to_enum(int id)
21396 {
21397
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 781 times.
✓ Branch 2 taken 781 times.
✓ Branch 3 taken 781 times.
✓ Branch 4 taken 781 times.
✓ Branch 5 taken 781 times.
✓ Branch 6 taken 698 times.
✓ Branch 7 taken 781 times.
✓ Branch 8 taken 781 times.
✓ Branch 9 taken 781 times.
✓ Branch 10 taken 781 times.
✓ Branch 11 taken 781 times.
✓ Branch 12 taken 781 times.
✓ Branch 13 taken 698 times.
✓ Branch 14 taken 698 times.
✓ Branch 15 taken 781 times.
✓ Branch 16 taken 781 times.
✓ Branch 17 taken 722 times.
✓ Branch 18 taken 698 times.
✓ Branch 19 taken 698 times.
✓ Branch 20 taken 698 times.
✓ Branch 21 taken 781 times.
✓ Branch 22 taken 781 times.
✓ Branch 23 taken 722 times.
✓ Branch 24 taken 698 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
18045 switch (id)
21398 {
21399 case ID_HEADER: return skip_header;
21400 781 case ID_RULES: return skip_rules;
21401 781 case ID_STRINGS: return skip_strings;
21402 781 case ID_MISC: return skip_misc;
21403 781 case ID_TILES: return skip_tiles;
21404 781 case ID_COMBOS: return skip_combos;
21405 698 case ID_COMBOALIASES: return skip_comboaliases;
21406 781 case ID_CSETS: return skip_csets;
21407 781 case ID_MAPS: return skip_maps;
21408 781 case ID_DMAPS: return skip_dmaps;
21409 781 case ID_DOORS: return skip_doors;
21410 781 case ID_ITEMS: return skip_items;
21411 781 case ID_WEAPONS: return skip_weapons;
21412 698 case ID_COLORS: return skip_colors;
21413 698 case ID_ICONS: return skip_icons;
21414 781 case ID_INITDATA: return skip_initdata;
21415 781 case ID_GUYS: return skip_guys;
21416 722 case ID_HEROSPRITES: return skip_herosprites;
21417 698 case ID_SUBSCREEN: return skip_subscreens;
21418 698 case ID_FFSCRIPT: return skip_ffscript;
21419 698 case ID_SFX: return skip_sfx;
21420 781 case ID_MIDIS: return skip_midis;
21421 781 case ID_CHEATS: return skip_cheats;
21422 722 case ID_ITEMDROPSETS: return skip_itemdropsets;
21423 698 case ID_FAVORITES: return skip_favorites;
21424 case ID_ZINFO: return skip_zinfo;
21425 }
21426
21427 return -1;
21428 18045 }
21429
21430 17637 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
21431 {
21432 17637 int section_enum = section_id_to_enum(section_id);
21433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17637 times.
17637 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21434
2/2
✓ Branch 0 taken 6594 times.
✓ Branch 1 taken 11043 times.
17637 if (skip)
21435 {
21436 word s_version;
21437
1/2
✓ Branch 0 taken 6594 times.
✗ Branch 1 not taken.
6594 if (!p_igetw(&s_version,f))
21438 {
21439 return qe_invalid;
21440 }
21441
21442
1/2
✓ Branch 0 taken 6594 times.
✗ Branch 1 not taken.
6594 if (!read_deprecated_section_cversion(f))
21443 {
21444 return qe_invalid;
21445 }
21446
21447
3/4
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 6280 times.
✓ Branch 2 taken 314 times.
✗ Branch 3 not taken.
6594 if (section_id == ID_RULES && s_version > 16)
21448 {
21449 dword dummy;
21450 if (!p_igetl(&dummy,f))
21451 {
21452 return qe_invalid;
21453 }
21454 }
21455
21456
3/4
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 6280 times.
✓ Branch 2 taken 314 times.
✗ Branch 3 not taken.
6594 if (section_id == ID_FFSCRIPT && s_version >= 18)
21457 {
21458 word dummy;
21459 if (!p_igetw(&dummy,f))
21460 {
21461 return qe_invalid;
21462 }
21463 }
21464
21465 dword section_length;
21466
1/2
✓ Branch 0 taken 6594 times.
✗ Branch 1 not taken.
6594 if (!p_igetl(&section_length,f))
21467 {
21468 return qe_invalid;
21469 }
21470
21471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6594 times.
6594 if (pack_fseek(f, section_length))
21472 {
21473 return qe_invalid;
21474 }
21475
21476
2/2
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 6280 times.
6594 if (!pack_feof(f))
21477 {
21478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6280 times.
6280 if (!p_mgetl(&section_id,f))
21479 {
21480 return qe_invalid;
21481 }
21482 6280 }
21483
21484 6594 return qe_cancel;
21485 }
21486
21487 11043 return qe_OK;
21488 17637 }
21489
21490 // TODO: this was copied from zc/zasm_utils.cpp
21491 325 static void _zasm_for_every_script(std::function<void(zasm_script*)> fn)
21492 {
21493 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
21494
21495 325 std::vector<zasm_script*> scripts;
21496
1/2
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
325 scripts.reserve(zasm_scripts.size());
21497
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 466075 times.
466400 for (auto& script : zasm_scripts)
21498
3/4
✓ Branch 0 taken 466075 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9529 times.
✓ Branch 3 taken 456546 times.
466075 if (script->valid())
21499
1/2
✓ Branch 0 taken 9529 times.
✗ Branch 1 not taken.
9529 scripts.push_back(script.get());
21500
21501
2/4
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 325 times.
325 std::for_each(scripts.begin(), scripts.end(), fn);
21502 325 }
21503
21504 466 static bool compat_qr_hide_bottom_pixels(const zquestheader& header)
21505 {
21506 // 2.55.9 or newer?
21507
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 331 times.
466 if (header.compareVer(2, 55, 9) >= 0)
21508 135 return false; // defer to whatever was set
21509
21510 // Only a couple quests take any time (~7ms) on my intel mac to check all the ZASM... cache those.
21511
1/2
✓ Branch 0 taken 331 times.
✗ Branch 1 not taken.
331 std::string title = header.title;
21512
3/4
✓ Branch 0 taken 331 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 328 times.
✓ Branch 3 taken 3 times.
331 if (title == "Stellar Seas")
21513 3 return false;
21514
3/4
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 325 times.
328 if (title == "Yuurand: Tales of the Labyrinth")
21515 3 return true;
21516
21517 // Look for ZASM setting values of 167, 168, etc. This is a sign that the script may be drawing something
21518 // near the old "bottom" of the screen, or is attempting to fill the entire screen with a draw command.
21519 // In these cases, the compat rule must be flipped on. As of writing, 72 quests in the PZC database match
21520 // this query: https://gist.github.com/connorjclark/edd12f84c9aac0c924ed328d3f8efcfa
21521 325 bool found = false;
21522
1/2
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
9854 _zasm_for_every_script([&](auto script){
21523
2/2
✓ Branch 0 taken 3064 times.
✓ Branch 1 taken 6465 times.
9529 if (found) return;
21524
21525
2/2
✓ Branch 0 taken 6432 times.
✓ Branch 1 taken 27637674 times.
27644106 for (const auto& instr : script->zasm)
21526 {
21527
4/4
✓ Branch 0 taken 24376146 times.
✓ Branch 1 taken 3261528 times.
✓ Branch 2 taken 476809 times.
✓ Branch 3 taken 23899337 times.
27637674 if (!(instr.command == SETV || instr.command == PUSHV)) continue;
21528
21529 3738337 int value = instr.arg2;
21530
9/10
✓ Branch 0 taken 3738334 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3738330 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 3738306 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 3738306 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 3738304 times.
3738337 if (value == 167000000 || value == 168000000 || value == 167870000 || value == 167910000 || value == 168130000)
21531 {
21532 33 found = true;
21533 33 break;
21534 }
21535 }
21536 9529 });
21537
21538 325 return found;
21539 466 }
21540
21541 //Internal function for loadquest wrapper
21542 781 static int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata)
21543 {
21544 781 DMapEditorLastMaptileUsed = 0;
21545 781 combosread=false;
21546 781 mapsread=false;
21547 781 fixffcs=false;
21548
21549 781 bool do_clear_scripts = !get_bit(skip_flags,skip_ffscript);
21550
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
21551 {
21552 set_bit(skip_flags, skip_ffscript, 1);
21553 setZScriptVersion(V_FFSCRIPT);
21554 FFCore.quest_format[vFFScript] = V_FFSCRIPT;
21555 FFCore.quest_format[vLastCompile] = V_FFSCRIPT;
21556 do_clear_scripts = true;
21557 }
21558
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 if(loading_tileset_flags & TILESET_CLEARMAPS)
21559 {
21560 set_bit(skip_flags, skip_maps, 1);
21561 }
21562
21563 // show_progress=true;
21564 char tmpfilename[L_tmpnam];
21565 781 temp_name(tmpfilename);
21566 // char percent_done[30];
21567 781 bool catchup=false;
21568 byte tempbyte;
21569 781 word old_map_count=map_count;
21570
21571 781 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21572 781 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21573 781 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21574
21575
2/2
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 315 times.
781 if(get_bit(skip_flags, skip_rules))
21576 {
21577 315 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21578 315 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21579 315 }
21580
21581 781 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21582 781 unpack_qrs();
21583 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21584
21585
2/2
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 315 times.
781 if(get_bit(skip_flags, skip_midis))
21586 {
21587 315 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21588 315 }
21589
21590
2/2
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 315 times.
781 if (!get_bit(skip_flags, skip_maps))
21591 466 Regions = {};
21592
21593
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 466 times.
781 if(do_clear_scripts)
21594 {
21595 466 zScript.clear();
21596 466 globalmap.clear();
21597 466 genericmap.clear();
21598 466 ffcmap.clear();
21599 466 itemmap.clear();
21600 466 npcmap.clear();
21601 466 ewpnmap.clear();
21602 466 lwpnmap.clear();
21603 466 playermap.clear();
21604 466 dmapmap.clear();
21605 466 screenmap.clear();
21606 466 itemspritemap.clear();
21607 466 comboscriptmap.clear();
21608 466 subscreenmap.clear();
21609
21610
2/2
✓ Branch 0 taken 238126 times.
✓ Branch 1 taken 466 times.
238592 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21611 {
21612 238126 ffcmap[i].clear();
21613 238126 }
21614
21615 466 globalmap[0].slotname = "Slot 1:";
21616 466 globalmap[0].scriptname = "~Init";
21617 466 globalmap[0].update();
21618
21619
2/2
✓ Branch 0 taken 3262 times.
✓ Branch 1 taken 466 times.
3728 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21620 {
21621 3262 globalmap[i].clear();
21622 3262 }
21623
21624
2/2
✓ Branch 0 taken 118830 times.
✓ Branch 1 taken 466 times.
119296 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21625 {
21626 118830 itemmap[i].clear();
21627 118830 }
21628
21629 //new script types -- prevent carrying over to a quest that you load after reading them
21630 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21631
2/2
✓ Branch 0 taken 118830 times.
✓ Branch 1 taken 466 times.
119296 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21632 {
21633 118830 npcmap[i].clear();
21634 118830 }
21635
2/2
✓ Branch 0 taken 118830 times.
✓ Branch 1 taken 466 times.
119296 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21636 {
21637 118830 lwpnmap[i].clear();
21638 118830 }
21639
2/2
✓ Branch 0 taken 118830 times.
✓ Branch 1 taken 466 times.
119296 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21640 {
21641 118830 ewpnmap[i].clear();
21642 118830 }
21643
2/2
✓ Branch 0 taken 1864 times.
✓ Branch 1 taken 466 times.
2330 for(int32_t i=0; i<NUMSCRIPTHERO-1; i++)
21644 {
21645 1864 playermap[i].clear();
21646 1864 }
21647
2/2
✓ Branch 0 taken 118830 times.
✓ Branch 1 taken 466 times.
119296 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21648 {
21649 118830 dmapmap[i].clear();
21650 118830 }
21651
2/2
✓ Branch 0 taken 118830 times.
✓ Branch 1 taken 466 times.
119296 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21652 {
21653 118830 screenmap[i].clear();
21654 118830 }
21655
2/2
✓ Branch 0 taken 118830 times.
✓ Branch 1 taken 466 times.
119296 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21656 {
21657 118830 itemspritemap[i].clear();
21658 118830 }
21659
2/2
✓ Branch 0 taken 238126 times.
✓ Branch 1 taken 466 times.
238592 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21660 {
21661 238126 comboscriptmap[i].clear();
21662 238126 }
21663
2/2
✓ Branch 0 taken 238126 times.
✓ Branch 1 taken 466 times.
238592 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21664 {
21665 238126 genericmap[i].clear();
21666 238126 }
21667
2/2
✓ Branch 0 taken 118830 times.
✓ Branch 1 taken 466 times.
119296 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN-1; i++)
21668 {
21669 118830 subscreenmap[i].clear();
21670 118830 }
21671
21672 466 reset_scripts();
21673 466 }
21674
21675 781 zquestheader tempheader{};
21676
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 tempheader.filename = filename;
21677
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 zinfo tempzi;
21678
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 tempzi.clear();
21679 781 load_tmp_zi = &tempzi;
21680
21681 // oldquest flag is set when an unencrypted qst file is suspected.
21682 781 bool oldquest = false;
21683 781 int32_t open_error=0;
21684
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21685
21686
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 if (!f)
21687 {
21688 ASSERT(open_error != 0);
21689 return open_error;
21690 }
21691 char zinfofilename[2048];
21692
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 replace_extension(zinfofilename, filename, "zinfo", 2047);
21693 781 int32_t ret=0;
21694
21695 //header
21696
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 box_out("Reading Header...");
21697
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 ret=readheader(f, &tempheader, printmetadata);
21698
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 781 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
781 checkstatus(ret);
21699
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 box_out("okay.");
21700
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 box_eol();
21701
21702
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 602 times.
781 if(read_zinfo)
21703 {
21704
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 box_out("Reading ZInfo - ");
21705
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 179 times.
✗ Branch 3 not taken.
179 box_out(read_ext_zinfo ? "External..." : "Internal...");
21706
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 176 times.
179 if(read_ext_zinfo)
21707 {
21708
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21709
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 ret=readzinfo(inf, tempzi, tempheader);
21710
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(inf) pack_fclose(inf);
21711
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
3 checkstatus(ret);
21712 3 }
21713 else
21714 {
21715
1/2
✓ Branch 0 taken 176 times.
✗ Branch 1 not taken.
176 ret=readzinfo(f, tempzi, tempheader);
21716
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
176 checkstatus(ret);
21717 }
21718
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 box_out("okay.");
21719
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 box_eol();
21720 179 }
21721
21722
2/2
✓ Branch 0 taken 757 times.
✓ Branch 1 taken 24 times.
781 if(tempheader.zelda_version>=0x193)
21723 {
21724 dword section_id;
21725
21726 //section id
21727
2/4
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
757 if(!p_mgetl(&section_id,f))
21728 {
21729 goto invalid;
21730 }
21731
21732 757 std::set<dword> seen_sections;
21733
21734
3/4
✓ Branch 0 taken 18394 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17637 times.
✓ Branch 3 taken 757 times.
18394 while(!pack_feof(f))
21735 {
21736
2/4
✓ Branch 0 taken 17637 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17637 times.
✗ Branch 3 not taken.
17637 if (seen_sections.contains(section_id))
21737 goto invalid;
21738
1/2
✓ Branch 0 taken 17637 times.
✗ Branch 1 not taken.
17637 seen_sections.insert(section_id);
21739
21740
3/4
✓ Branch 0 taken 17637 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11043 times.
✓ Branch 3 taken 6594 times.
17637 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
21741 {
21742
1/2
✓ Branch 0 taken 6594 times.
✗ Branch 1 not taken.
6594 if (retval == qe_cancel)
21743 6594 continue;
21744 checkstatus(retval);
21745 }
21746
21747
24/25
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 443 times.
✓ Branch 2 taken 757 times.
✓ Branch 3 taken 757 times.
✓ Branch 4 taken 443 times.
✓ Branch 5 taken 384 times.
✓ Branch 6 taken 757 times.
✓ Branch 7 taken 443 times.
✓ Branch 8 taken 443 times.
✓ Branch 9 taken 443 times.
✓ Branch 10 taken 443 times.
✓ Branch 11 taken 443 times.
✓ Branch 12 taken 384 times.
✓ Branch 13 taken 384 times.
✓ Branch 14 taken 443 times.
✓ Branch 15 taken 443 times.
✓ Branch 16 taken 384 times.
✓ Branch 17 taken 384 times.
✓ Branch 18 taken 384 times.
✓ Branch 19 taken 384 times.
✓ Branch 20 taken 443 times.
✓ Branch 21 taken 443 times.
✓ Branch 22 taken 384 times.
✓ Branch 23 taken 384 times.
✗ Branch 24 not taken.
11043 switch(section_id)
21748 {
21749 case ID_RULES:
21750
21751 //rules
21752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(catchup)
21753 {
21754 box_out("found.");
21755 box_eol();
21756 catchup=false;
21757 }
21758
21759
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("Reading Rules...");
21760
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 ret=readrules(f, &tempheader);
21761
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
443 checkstatus(ret);
21762
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("okay.");
21763
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_eol();
21764 443 break;
21765
21766 case ID_STRINGS:
21767
21768 //strings
21769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(catchup)
21770 {
21771 box_out("found.");
21772 box_eol();
21773 catchup=false;
21774 }
21775
21776
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("Reading Strings...");
21777
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 ret=readstrings(f, &tempheader);
21778
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
443 checkstatus(ret);
21779
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("okay.");
21780
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_eol();
21781 443 break;
21782
21783 case ID_MISC:
21784
21785 //misc data
21786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 757 times.
757 if(catchup)
21787 {
21788 box_out("found.");
21789 box_eol();
21790 catchup=false;
21791 }
21792
21793
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 box_out("Reading Misc. Data...");
21794
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 ret=readmisc(f, &tempheader, Misc);
21795
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 757 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
757 checkstatus(ret);
21796
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 box_out("okay.");
21797
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 box_eol();
21798 757 break;
21799
21800 case ID_TILES:
21801
21802 //tiles
21803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 757 times.
757 if(catchup)
21804 {
21805 box_out("found.");
21806 box_eol();
21807 catchup=false;
21808 }
21809
21810
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 box_out("Reading Tiles...");
21811
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
21812
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 757 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
757 checkstatus(ret);
21813
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 box_out("okay.");
21814
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 box_eol();
21815 757 break;
21816
21817 case ID_COMBOS:
21818
21819 //combos
21820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(catchup)
21821 {
21822 box_out("found.");
21823 box_eol();
21824 catchup=false;
21825 }
21826
21827
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("Reading Combos...");
21828
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
21829 443 combosread=true;
21830
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
443 checkstatus(ret);
21831
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("okay.");
21832
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_eol();
21833 443 break;
21834
21835 case ID_COMBOALIASES:
21836
21837 //combo aliases
21838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(catchup)
21839 {
21840 box_out("found.");
21841 box_eol();
21842 catchup=false;
21843 }
21844
21845
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("Reading Combo Aliases...");
21846
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
21847
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
384 checkstatus(ret);
21848
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("okay.");
21849
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_eol();
21850 384 break;
21851
21852 case ID_CSETS:
21853
21854 //color data
21855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 757 times.
757 if(catchup)
21856 {
21857 box_out("found.");
21858 box_eol();
21859 catchup=false;
21860 }
21861
21862
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 box_out("Reading Color Data...");
21863
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
21864
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 757 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
757 checkstatus(ret);
21865
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 box_out("okay.");
21866
1/2
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
757 box_eol();
21867 757 break;
21868
21869 case ID_MAPS:
21870
21871 //maps
21872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(catchup)
21873 {
21874 box_out("found.");
21875 box_eol();
21876 catchup=false;
21877 }
21878
21879
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("Reading Maps...");
21880
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 ret=readmaps(f, &tempheader);
21881 443 mapsread=true;
21882
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
443 checkstatus(ret);
21883
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("okay.");
21884
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_eol();
21885 443 break;
21886
21887 case ID_DMAPS:
21888
21889 //dmaps
21890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(catchup)
21891 {
21892 box_out("found.");
21893 box_eol();
21894 catchup=false;
21895 }
21896
21897
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("Reading DMaps...");
21898
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
21899
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
443 checkstatus(ret);
21900
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("okay.");
21901
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_eol();
21902 443 break;
21903
21904 case ID_DOORS:
21905
21906 //door combo sets
21907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(catchup)
21908 {
21909 box_out("found.");
21910 box_eol();
21911 catchup=false;
21912 }
21913
21914
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("Reading Doors...");
21915
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 ret=readdoorcombosets(f, &tempheader);
21916
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
443 checkstatus(ret);
21917
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("okay.");
21918
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_eol();
21919 443 break;
21920
21921 case ID_ITEMS:
21922
21923 //items
21924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(catchup)
21925 {
21926 box_out("found.");
21927 box_eol();
21928 catchup=false;
21929 }
21930
21931
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("Reading Items...");
21932
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 ret=readitems(f, tempheader.zelda_version, tempheader.build);
21933
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
443 checkstatus(ret);
21934
21935
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("okay.");
21936
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_eol();
21937 443 break;
21938
21939 case ID_WEAPONS:
21940
21941 //weapons
21942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(catchup)
21943 {
21944 box_out("found.");
21945 box_eol();
21946 catchup=false;
21947 }
21948
21949
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("Reading Weapons...");
21950
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 ret=readweapons(f, &tempheader);
21951
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
443 checkstatus(ret);
21952
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("okay.");
21953
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_eol();
21954 443 break;
21955
21956 case ID_COLORS:
21957
21958 //misc. colors
21959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(catchup)
21960 {
21961 box_out("found.");
21962 box_eol();
21963 catchup=false;
21964 }
21965
21966
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("Reading Misc. Colors...");
21967
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 ret=readmisccolors(f, &tempheader, Misc);
21968
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
384 checkstatus(ret);
21969
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("okay.");
21970
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_eol();
21971 384 break;
21972
21973 case ID_ICONS:
21974
21975 //game icons
21976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(catchup)
21977 {
21978 box_out("found.");
21979 box_eol();
21980 catchup=false;
21981 }
21982
21983
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("Reading Game Icons...");
21984
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 ret=readgameicons(f, &tempheader, Misc);
21985
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
384 checkstatus(ret);
21986
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("okay.");
21987
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_eol();
21988 384 break;
21989
21990 case ID_INITDATA:
21991
21992 //initialization data
21993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(catchup)
21994 {
21995 box_out("found.");
21996 box_eol();
21997 catchup=false;
21998 }
21999
22000
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("Reading Init. Data...");
22001
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 ret=readinitdata(f, &tempheader);
22002
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
443 checkstatus(ret);
22003
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("okay.");
22004
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_eol();
22005
22006
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 443 times.
443 if(!get_bit(skip_flags, skip_subscreens))
22007 {
22008
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 350 times.
443 if(subscr_mode!=ssdtMAX) //not using custom subscreens
22009 {
22010
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 setupsubscreens();
22011
22012
2/2
✓ Branch 0 taken 47616 times.
✓ Branch 1 taken 93 times.
47709 for(int32_t i=0; i<MAXDMAPS; ++i)
22013 {
22014 47616 int32_t type=DMaps[i].type&dmfTYPE;
22015
2/2
✓ Branch 0 taken 1085 times.
✓ Branch 1 taken 46531 times.
47616 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22016 47616 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22017 47616 }
22018 93 }
22019 443 }
22020
22021
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!get_bit(skip_flags, skip_sfx))
22022 {
22023 443 setupsfx();
22024 443 }
22025
22026
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!get_bit(skip_flags, skip_itemdropsets))
22027 {
22028
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 init_item_drop_sets();
22029 443 }
22030
22031
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 443 times.
443 if(!get_bit(skip_flags, skip_favorites))
22032 {
22033 443 init_favorites();
22034 443 }
22035
22036 443 break;
22037
22038 case ID_GUYS:
22039
22040 //guys
22041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(catchup)
22042 {
22043 box_out("found.");
22044 box_eol();
22045 catchup=false;
22046 }
22047
22048
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("Reading Custom Guy Data...");
22049
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 ret=readguys(f, &tempheader);
22050
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
443 checkstatus(ret);
22051
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("okay.");
22052
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_eol();
22053 443 break;
22054
22055 case ID_HEROSPRITES:
22056
22057 //hero sprites
22058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(catchup)
22059 {
22060 box_out("found.");
22061 box_eol();
22062 catchup=false;
22063 }
22064
22065
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("Reading Custom Hero Sprite Data...");
22066
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 ret=readherosprites(f, &tempheader);
22067
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
384 checkstatus(ret);
22068
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("okay.");
22069
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_eol();
22070 384 break;
22071
22072 case ID_SUBSCREEN:
22073
22074 //custom subscreens
22075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(catchup)
22076 {
22077 box_out("found.");
22078 box_eol();
22079 catchup=false;
22080 }
22081
22082
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("Reading Custom Subscreen Data...");
22083
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 ret=readsubscreens(f);
22084
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
384 checkstatus(ret);
22085
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("okay.");
22086
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_eol();
22087 384 break;
22088
22089 case ID_FFSCRIPT:
22090
22091 //Freeform combo scripts
22092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(catchup)
22093 {
22094 box_out("found.");
22095 box_eol();
22096 catchup=false;
22097 }
22098
22099
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("Reading FF Script Data...");
22100
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 ret=readffscript(f, &tempheader);
22101
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
384 checkstatus(ret);
22102
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("okay.");
22103
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_eol();
22104 384 break;
22105
22106 case ID_SFX:
22107
22108 //SFX data
22109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(catchup)
22110 {
22111 box_out("found.");
22112 box_eol();
22113 catchup=false;
22114 }
22115
22116
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("Reading SFX Data...");
22117
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 ret=readsfx(f, &tempheader);
22118
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
384 checkstatus(ret);
22119
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("okay.");
22120
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_eol();
22121 384 break;
22122
22123 case ID_MIDIS:
22124
22125 //midis
22126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(catchup)
22127 {
22128 box_out("found.");
22129 box_eol();
22130 catchup=false;
22131 }
22132
22133
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("Reading Tunes...");
22134
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 ret=readtunes(f, &tempheader, tunes);
22135
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
443 checkstatus(ret);
22136
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("okay.");
22137
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_eol();
22138 443 break;
22139
22140 case ID_CHEATS:
22141
22142 //cheat codes
22143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(catchup)
22144 {
22145 box_out("found.");
22146 box_eol();
22147 catchup=false;
22148 }
22149
22150
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("Reading Cheat Codes...");
22151
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 ret=readcheatcodes(f, &tempheader);
22152
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
443 checkstatus(ret);
22153
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("okay.");
22154
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_eol();
22155 443 break;
22156
22157 case ID_ITEMDROPSETS:
22158
22159 //item drop sets
22160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(catchup)
22161 {
22162 box_out("found.");
22163 box_eol();
22164 catchup=false;
22165 }
22166
22167
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("Reading Item Drop Sets...");
22168
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 ret=readitemdropsets(f, tempheader.zelda_version);
22169
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
384 checkstatus(ret);
22170
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("okay.");
22171
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_eol();
22172 384 break;
22173
22174 case ID_FAVORITES:
22175
22176 //favorite combos and combo aliases
22177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(catchup)
22178 {
22179 box_out("found.");
22180 box_eol();
22181 catchup=false;
22182 }
22183
22184
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("Reading Favorite Combos...");
22185
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 ret=readfavorites(f, tempheader.zelda_version);
22186
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
384 checkstatus(ret);
22187
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("okay.");
22188
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_eol();
22189 384 break;
22190
22191 default:
22192 if(!catchup)
22193 {
22194 box_out("Bad token! Searching...");
22195 box_eol();
22196 }
22197
22198 catchup=true;
22199 break;
22200 }
22201
22202
22203
1/2
✓ Branch 0 taken 11043 times.
✗ Branch 1 not taken.
11043 if(catchup)
22204 {
22205 //section id
22206 section_id=(section_id<<8);
22207
22208 if(!p_getc(&tempbyte,f))
22209 {
22210 goto invalid;
22211 }
22212
22213 section_id+=tempbyte;
22214 }
22215
22216 else
22217 {
22218 //section id
22219
3/4
✓ Branch 0 taken 11043 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10600 times.
✓ Branch 3 taken 443 times.
11043 if(!pack_feof(f))
22220 {
22221
2/4
✓ Branch 0 taken 10600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10600 times.
✗ Branch 3 not taken.
10600 if(!p_mgetl(&section_id,f))
22222 {
22223 goto invalid;
22224 }
22225 10600 }
22226 }
22227 }
22228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 757 times.
757 }
22229 else
22230 {
22231
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
22232
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
22233
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
22234
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
22235
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
22236
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
22237
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
22238
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
22239
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
22240
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
22241
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
22242
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
22243
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
22244
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Tunes", ID_MIDIS, [&](){ return readtunes(f, &tempheader, tunes); }},
22245
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
22246
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
22247
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Hero Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1); }},
22248
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1); }},
22249 };
22250
22251 24 legacy_skip_flags = skip_flags;
22252
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 408 times.
1250 for (auto& [desc, section_id, fn] : hardcoded_sections)
22253 {
22254
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 int section_enum = section_id_to_enum(section_id);
22255
2/4
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 408 times.
✗ Branch 3 not taken.
408 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
22256
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 16 times.
408 if (skip)
22257 {
22258 // Nothing to read.
22259
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 15 times.
16 if (section_id == ID_RULES)
22260 1 continue;
22261
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 14 times.
15 if (section_id == ID_GUYS)
22262 1 continue;
22263
22264 // Haven't looked at how to skip these, because we don't need to currently: the only
22265 // usage of skip_flags currently is all off except: header and tiles (see `load_imagebuf`).
22266
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (section_id == ID_MIDIS)
22267 1 continue;
22268
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12 times.
13 if (section_id == ID_CHEATS)
22269 1 continue;
22270
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11 times.
12 if (section_id == ID_INITDATA)
22271 1 continue;
22272
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if (section_id == ID_HEROSPRITES)
22273 1 continue;
22274
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9 times.
10 if (section_id == ID_ITEMDROPSETS)
22275 1 continue;
22276 9 }
22277
22278 // Would be nice, but old sections mostly did not save section sizes. We could advance by
22279 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
22280 // read all the sections even if requested to skip some.
22281 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22282 // {
22283 // if (retval == qe_cancel)
22284 // continue;
22285 // checkstatus(retval);
22286 // }
22287
22288
3/6
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 401 times.
✗ Branch 5 not taken.
802 box_out(fmt::format("Reading {}...", desc).c_str());
22289
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 ret = fn();
22290
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 401 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
401 checkstatus(ret);
22291
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_out("okay.");
22292
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_eol();
22293 }
22294 24 legacy_skip_flags = nullptr;
22295
22296
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_subscreens))
22297 {
22298
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 setupsubscreens();
22299
22300
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 23 times.
11799 for(int32_t i=0; i<MAXDMAPS; ++i)
22301 {
22302 11776 int32_t type=DMaps[i].type&dmfTYPE;
22303
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11732 times.
11776 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22304 11776 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22305 11776 }
22306 23 }
22307
22308
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("Setting Up Default Sound Effects...");
22309
22310
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 23 times.
24 if(!get_bit(skip_flags, skip_sfx))
22311 23 setupsfx();
22312
22313
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_favorites))
22314 23 init_favorites();
22315
22316
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("okay.");
22317
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_eol();
22318
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
24 }
22319
22320
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 init_spritelists();
22321
22322 // check data
22323
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 if(f)
22324 {
22325
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 pack_fclose(f);
22326 781 }
22327
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 clear_quest_tmpfile();
22328
22329
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 if(!oldquest)
22330 {
22331
2/4
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 781 times.
781 if(exists(tmpfilename))
22332 {
22333 delete_file(tmpfilename);
22334 }
22335 781 }
22336
22337
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 781 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
781 if(fixffcs && combosread && mapsread)
22338 {
22339 for(int32_t i=0; i<map_count; i++)
22340 {
22341 for(int32_t j=0; j<MAPSCRS; j++)
22342 {
22343 int c = TheMaps[(i*MAPSCRS)+j].numFFC();
22344 for(int32_t m=0; m<c; m++)
22345 {
22346 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].data].type == cCHANGE)
22347 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffc_changer;
22348 }
22349 }
22350 }
22351 }
22352
22353
3/4
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 466 times.
✓ Branch 3 taken 315 times.
781 if (!get_bit(skip_flags, skip_rules))
22354 {
22355
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 bool should_hide = compat_qr_hide_bottom_pixels(tempheader);
22356
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 al_trace("Note: qr_HIDE_BOTTOM_8_PIXELS %s via compat rule\n", should_hide ? "enabled" : "disabled");
22357
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 430 times.
466 if (should_hide)
22358
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 set_qr(qr_HIDE_BOTTOM_8_PIXELS, 1);
22359
22360
3/4
✓ Branch 0 taken 349 times.
✓ Branch 1 taken 117 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 349 times.
466 if (FFCore.quest_format[vCompatRule] < 77 && Header->is_z3)
22361 set_qr(qr_LAYER6_STRINGS_OVER_SUBSCREEN, 1);
22362 466 }
22363
22364
7/10
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 717 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 63 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 63 times.
✗ Branch 9 not taken.
781 if(get_qr(qr_CONTFULL_DEP) && !get_bit(skip_flags, skip_rules) && !get_bit(skip_flags, skip_initdata))
22365 {
22366
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 set_qr(qr_CONTFULL_DEP, 0);
22367
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 zinit.flags.set(INIT_FL_CONTPERCENT,true);
22368 63 zinit.cont_heart=100;
22369 63 zinit.counter[crLIFE]=zinit.mcounter[crLIFE];
22370 63 }
22371
22372
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 box_out("Done.");
22373
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 box_eol();
22374
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 box_end(false);
22375
22376
3/4
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 467 times.
✓ Branch 3 taken 314 times.
781 if(!get_bit(skip_flags, skip_header))
22377 {
22378
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 *Header = tempheader;
22379 467 }
22380
3/4
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 466 times.
✓ Branch 3 taken 315 times.
781 if(!get_bit(skip_flags, skip_zinfo))
22381 {
22382
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 ZI.copyFrom(tempzi);
22383 466 }
22384
22385
3/4
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 466 times.
✓ Branch 3 taken 315 times.
781 if(get_bit(skip_flags, skip_maps))
22386 {
22387 315 map_count=old_map_count;
22388 315 }
22389
22390
3/4
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 315 times.
✓ Branch 3 taken 466 times.
781 if(get_bit(skip_flags, skip_rules))
22391 {
22392 315 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22393 315 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22394
1/2
✓ Branch 0 taken 315 times.
✗ Branch 1 not taken.
315 unpack_qrs();
22395 315 }
22396
22397
3/4
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 315 times.
✓ Branch 3 taken 466 times.
781 if(get_bit(skip_flags, skip_midis))
22398 {
22399 315 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22400 315 }
22401
22402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 781 times.
781 if(loading_tileset_flags & TILESET_CLEARMAPS)
22403 {
22404 TheMaps.clear();
22405 TheMaps.resize(MAPSCRS*1);
22406 map_count = 1;
22407 map_autolayers.clear();
22408 map_autolayers.resize(6*1);
22409 }
22410
22411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 781 times.
781 if(loading_tileset_flags & TILESET_CLEARHEADER)
22412 {
22413 memset(Header->password, 0, sizeof(Header->password));
22414 memset(Header->minver, 0, sizeof(Header->minver));
22415 memset(Header->title, 0, sizeof(Header->title));
22416 memset(Header->author, 0, sizeof(Header->author));
22417 memset(Header->version, 0, sizeof(Header->version));
22418 Header->use_keyfile = 0;
22419 Header->dirty_password = false;
22420 cvs_MD5Context ctx;
22421 cvs_MD5Init(&ctx);
22422 cvs_MD5Update(&ctx, (const uint8_t*)"", 0);
22423 cvs_MD5Final(Header->pwd_hash, &ctx);
22424 }
22425
22426
3/4
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 466 times.
✓ Branch 3 taken 315 times.
781 if (!get_bit(skip_flags, skip_maps))
22427 {
22428 // Not needed, so release its memory.
22429
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 old_combo_pages = {};
22430 466 }
22431
22432 781 return qe_OK;
22433
22434 invalid:
22435 // TODO: It's too easy to forget to jump to this label, and accidentally leave the file open.
22436 // Should wrap PACKFILE in a std::unique_pointer with a custom deallocator.
22437 box_out("error.");
22438 box_eol();
22439 box_end(true);
22440
22441 pack_fclose(f);
22442
22443 if(!oldquest)
22444 {
22445 if(exists(tmpfilename))
22446 {
22447 delete_file(tmpfilename);
22448 }
22449 }
22450
22451 return qe_invalid;
22452
22453 781 }
22454
22455 static bool _is_loading_quest;
22456
22457 bool is_loading_quest()
22458 {
22459 return _is_loading_quest;
22460 }
22461
22462 314 std::string get_last_loaded_qstpath()
22463 {
22464 314 return last_loaded_qstpath;
22465 }
22466
22467 781 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc,
22468 zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata,
22469 bool report, byte qst_num, dword tilesetflags)
22470 {
22471 781 loading_tileset_flags = tilesetflags;
22472 781 const char* basename = get_filename(filename);
22473 781 zapp_reporting_add_breadcrumb("load_quest", basename);
22474 781 zapp_reporting_set_tag("qst.filename", basename);
22475
22476 781 last_loaded_qstpath = filename;
22477 781 loading_qst_name = filename;
22478 781 loading_qst_num = qst_num;
22479 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22480 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22481
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 if (!is_ci())
22482 loadquest_report = report;
22483
22484 781 _is_loading_quest = true;
22485 781 auto start = std::chrono::steady_clock::now();
22486 781 zprint2("Loading qst: %s\n", filename);
22487 781 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
22488 781 int32_t load_ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count();
22489 781 zprint2("Time to load qst: %d ms\n", load_ms);
22490 781 _is_loading_quest = false;
22491
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 if (ret)
22492 zprint2("Error: %s\n", qst_error[ret]);
22493
22494
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 if(show_progress)
22495 {
22496 if(ret)
22497 {
22498 box_out("-- Error loading quest file! --");
22499 box_out(fmt::format("Error: {}", qst_error[ret]).c_str());
22500 box_end(true);
22501 }
22502 else box_end(false);
22503 }
22504
22505 781 load_tmp_zi = NULL;
22506 781 loading_qst_name = NULL;
22507 781 loadquest_report = false;
22508 781 loading_qst_num = 0;
22509
22510 781 zapp_reporting_set_tag("qst.author", Header->author);
22511 781 zapp_reporting_set_tag("qst.title", Header->title);
22512 781 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
22513
22514 781 return ret;
22515 }
22516